wrstudios/frodata

View on GitHub

Showing 507 of 507 total issues

Assignment Branch Condition size for << is too high. [18.63/15]
Open

    def <<(entity)
      url_chunk, options = setup_entity_post_request(entity)
      result = execute_entity_post_request(options, url_chunk)
      if entity.is_new?
        doc = ::Nokogiri::XML(result.body).remove_namespaces!
Severity: Minor
Found in lib/frodata/entity_set.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method has too many lines. [13/10]
Open

        def value_to_xml(value, xml_builder)
          if value.is_a?(Hash)
            value.each do |key, val|
              xml_builder['gml'].send(key) do
                value_to_xml(val, xml_builder)

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [13/10]
Open

      def check_content_type
        # Dynamically extend instance with methods for
        # processing the current result type
        if is_atom?
          extend FrOData::Service::Response::Atom
Severity: Minor
Found in lib/frodata/service/response.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [13/10]
Open

    def get_property(property_name)
      prop_name = property_name.to_s
      # Property is lazy loaded
      if properties_xml_value.has_key?(prop_name)
        property = instantiate_property(prop_name, properties_xml_value[prop_name])
Severity: Minor
Found in lib/frodata/entity.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Complex method FrOData::Entity::process_links (39.6)
Open

    def self.process_links(entity, xml_doc)
      entity.instance_eval do
        new_links = instance_variable_get(:@links) || {}
        schema.navigation_properties[name].each do |nav_name, details|
          xml_doc.xpath("./link[@title='#{nav_name}']").each do |node|
Severity: Minor
Found in lib/frodata/entity.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Method has too many lines. [12/10]
Open

    def execute_entity_post_request(options, url_chunk)
      result = service.execute(url_chunk, options)
      unless result.code.to_s =~ /^2[0-9][0-9]$/
        service.logger.debug <<-EOS
          [ODATA: #{service_name}]
Severity: Minor
Found in lib/frodata/entity_set.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [12/10]
Open

    def self.process_metadata(entity, metadata)
      entity.instance_eval do
        new_links = instance_variable_get(:@links) || {}
        schema.navigation_properties[name].each do |nav_name, details|
          href = metadata["#{nav_name}@odata.navigationLink"]
Severity: Minor
Found in lib/frodata/entity.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [12/10]
Open

    def read_metadata
      # From file, good for debugging
      if options[:metadata_file]
        data = File.read(options[:metadata_file])
        ::Nokogiri::XML(data).remove_namespaces!
Severity: Minor
Found in lib/frodata/service.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Perceived complexity for validate is too high. [8/7]
Open

      def validate(value)
        return [] if value.nil? && allows_nil?
        values = parse_value(value)

        if values.length > 1 && !is_flags?
Severity: Minor
Found in lib/frodata/properties/enum.rb by rubocop

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

Method has too many lines. [11/10]
Open

    def setup_entity_post_request(entity)
      primary_key = entity.get_property(entity.primary_key).url_value
      chunk = entity.is_new? ? name : "#{name}(#{primary_key})"
      options = {
          method: :post,
Severity: Minor
Found in lib/frodata/entity_set.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Cyclomatic complexity for validate is too high. [7/6]
Open

      def validate(value)
        return [] if value.nil? && allows_nil?
        values = parse_value(value)

        if values.length > 1 && !is_flags?
Severity: Minor
Found in lib/frodata/properties/enum.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Method has too many lines. [11/10]
Open

    def <<(entity)
      url_chunk, options = setup_entity_post_request(entity)
      result = execute_entity_post_request(options, url_chunk)
      if entity.is_new?
        doc = ::Nokogiri::XML(result.body).remove_namespaces!
Severity: Minor
Found in lib/frodata/entity_set.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [11/10]
Open

    def navigation_properties
      @navigation_properties ||= metadata.xpath('//EntityType').map do |entity_type_def|
        [
          entity_type_def.attributes['Name'].value,
          entity_type_def.xpath('./NavigationProperty').map do |nav_property_def|
Severity: Minor
Found in lib/frodata/schema.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [11/10]
Open

    def [](entity_set_name)
      xpath_query = "//EntitySet[@Name='#{entity_set_name}']"
      entity_set_node = metadata.xpath(xpath_query).first
      raise ArgumentError, "Unknown Entity Set: #{entity_set_name}" if entity_set_node.nil?
      entity_type = entity_set_node.attributes['EntityType'].value
Severity: Minor
Found in lib/frodata/entity_container.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for read_metadata is too high. [16.55/15]
Open

    def read_metadata
      # From file, good for debugging
      if options[:metadata_file]
        data = File.read(options[:metadata_file])
        ::Nokogiri::XML(data).remove_namespaces!
Severity: Minor
Found in lib/frodata/service.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for execute_entity_post_request is too high. [15.07/15]
Open

    def execute_entity_post_request(options, url_chunk)
      result = service.execute(url_chunk, options)
      unless result.code.to_s =~ /^2[0-9][0-9]$/
        service.logger.debug <<-EOS
          [ODATA: #{service_name}]
Severity: Minor
Found in lib/frodata/entity_set.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Complex method FrOData::Properties::Enum#validate (30.1)
Open

      def validate(value)
        return [] if value.nil? && allows_nil?
        values = parse_value(value)

        if values.length > 1 && !is_flags?
Severity: Minor
Found in lib/frodata/properties/enum.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method FrOData::Entity#to_xml (28.5)
Open

    def to_xml
      namespaces = XML_NAMESPACES.merge('xml:base' => service.service_url)
      builder = Nokogiri::XML::Builder.new do |xml|
        xml.entry(namespaces) do
          xml.category(term: type,
Severity: Minor
Found in lib/frodata/entity.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method FrOData::NavigationProperty::Proxy#fetch_result (27.7)
Open

      def fetch_result
        raise "Invalid navigation link for #{nav_name}" unless link[:href]

        options = {
          type:         nav_property.entity_type,

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Method read_metadata has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def read_metadata
      # From file, good for debugging
      if options[:metadata_file]
        data = File.read(options[:metadata_file])
        ::Nokogiri::XML(data).remove_namespaces!
Severity: Minor
Found in lib/frodata/service.rb - About 55 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Severity
Category
Status
Source
Language