Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotated EnumType Members #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

sosso
Copy link

@sosso sosso commented Oct 21, 2020

Hi,

We're also doing a lot more with RESO Web APIs these days, and we needed Annotations surfaced so I whipped this up. I couldn't get Ruby 2.2 installed locally because it's EOL, so let me know how you want to handle that part of this PR; I don't need any higher ruby version functionality from what I added. I also fixed what appeared to be a broken spec as part of the Shared Examples file.

@@ -89,6 +94,18 @@ def collect_members
member_value = member_xml.attributes['Value'].andand.value.andand.to_i
[member_value || index, member_name]
end]
end

def collect_annotated_members
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Complex method FrOData::Schema::EnumType#collect_annotated_members (35.9)


def collect_annotated_members
Hash[type_definition.xpath('./Member').map.with_index do |member_xml, index|
member_name = member_xml.attributes['Name'].value
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FrOData::Schema::EnumType#collect_annotated_members calls 'member_xml.attributes' 2 times

member_name = member_xml.attributes['Name'].value
member_value = member_xml.attributes['Value'].andand.value.andand.to_i
annotation = nil
if member_xml.element_children.count > 0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FrOData::Schema::EnumType#collect_annotated_members calls 'member_xml.element_children' 2 times


def collect_annotated_members
Hash[type_definition.xpath('./Member').map.with_index do |member_xml, index|
member_name = member_xml.attributes['Name'].value
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FrOData::Schema::EnumType#collect_annotated_members refers to 'member_xml' more than self (maybe move it to another class?)

@@ -89,6 +94,18 @@ def collect_members
member_value = member_xml.attributes['Value'].andand.value.andand.to_i
[member_value || index, member_name]
end]
end

def collect_annotated_members
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FrOData::Schema::EnumType#collect_annotated_members has approx 6 statements

if member_xml.element_children.count > 0
annotation = member_xml.element_children.last.attribute('String').value
end
[member_value || index, {name: member_name, annotation: annotation}]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space inside { missing.

if member_xml.element_children.count > 0
annotation = member_xml.element_children.last.attribute('String').value
end
[member_value || index, {name: member_name, annotation: annotation}]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space inside } missing.

@@ -46,18 +46,23 @@ def namespace
# @return [Hash]
def members
@members ||= collect_members
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

end at 49, 8 is not aligned with def at 47, 6.

@@ -89,6 +94,18 @@ def collect_members
member_value = member_xml.attributes['Value'].andand.value.andand.to_i
[member_value || index, member_name]
end]
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

end at 97, 8 is not aligned with def at 91, 6.

@@ -89,6 +94,18 @@ def collect_members
member_value = member_xml.attributes['Value'].andand.value.andand.to_i
[member_value || index, member_name]
end]
end

def collect_annotated_members
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assignment Branch Condition size for collect_annotated_members is too high. [21.47/15]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant