influencemapping/whos_got_dirt-gem

View on GitHub

Showing 15 of 15 total issues

Method walk has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def walk(node, data)
      case node
      when Hash
        hash = {}
        node.each do |key,value|
Severity: Minor
Found in lib/whos_got_dirt/renderer.rb - About 1 hr 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

Method all_of has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def all_of(target, source, opts = {})
      params = parameters(opts)

      if params[source]
        equal(target, source, opts)
Severity: Minor
Found in lib/whos_got_dirt/request.rb - About 1 hr 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

Method convert has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def convert
          match('company_name', 'name')
          equal('limit', 'limit') # default 100
          equal('index', 'page', transform: lambda{|v| (Integer(v) - 1) * (Integer(input['limit'] || 100))})

Severity: Minor
Found in lib/whos_got_dirt/requests/entity/corp_watch.rb - About 1 hr to fix

    Method walk has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def walk(node, data)
          case node
          when Hash
            hash = {}
            node.each do |key,value|
    Severity: Minor
    Found in lib/whos_got_dirt/renderer.rb - About 1 hr to fix

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

              def item_url(result)
                query = CGI.parse(env.url.query.to_s)
                "#{env.url.scheme}://#{env.url.host}/concession/#{result['identifiers'][0]['identifier']}?apikey=#{CGI.escape(query['apikey'][0].to_s)}"
      Severity: Major
      Found in lib/whos_got_dirt/responses/relation/open_oil.rb and 2 other locations - About 40 mins to fix
      lib/whos_got_dirt/responses/entity/little_sis.rb on lines 72..74
      lib/whos_got_dirt/responses/list/little_sis.rb on lines 48..50

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 38.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

              def item_url(result)
                query = CGI.parse(env.url.query.to_s)
                "#{env.url.scheme}://#{env.url.host}/list/#{result['identifiers'][0]['identifier']}.xml?_key=#{CGI.escape(query['_key'][0].to_s)}"
      Severity: Major
      Found in lib/whos_got_dirt/responses/list/little_sis.rb and 2 other locations - About 40 mins to fix
      lib/whos_got_dirt/responses/entity/little_sis.rb on lines 72..74
      lib/whos_got_dirt/responses/relation/open_oil.rb on lines 82..84

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 38.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

              def item_url(result)
                query = CGI.parse(env.url.query.to_s)
                "#{env.url.scheme}://#{env.url.host}/entity/#{result['identifiers'][0]['identifier']}.xml?_key=#{CGI.escape(query['_key'][0].to_s)}"
      Severity: Major
      Found in lib/whos_got_dirt/responses/entity/little_sis.rb and 2 other locations - About 40 mins to fix
      lib/whos_got_dirt/responses/list/little_sis.rb on lines 48..50
      lib/whos_got_dirt/responses/relation/open_oil.rb on lines 82..84

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 38.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Consider simplifying this complex logical expression.
      Open

            elsif params["#{source}>="] || params["#{source}>"] || params["#{source}<="] || params["#{source}<"]
              output[target] = "#{params["#{source}>="] || params["#{source}>"]}:#{params["#{source}<="] || params["#{source}<"]}"
      Severity: Major
      Found in lib/whos_got_dirt/request.rb - About 40 mins to fix

        Method convert has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

                def convert
                  match('company_name', 'name')
                  equal('limit', 'limit') # default 100
                  equal('index', 'page', transform: lambda{|v| (Integer(v) - 1) * (Integer(input['limit'] || 100))})
        
        
        Severity: Minor
        Found in lib/whos_got_dirt/requests/entity/corp_watch.rb - About 35 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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                  input['contact_details'] && input['contact_details'].each do |contact_detail|
                    if contact_detail['type'] == 'address' && (contact_detail['value'] || contact_detail['value~='])
                      output['registered_address'] = contact_detail['value'] || contact_detail['value~=']
                    end
        Severity: Minor
        Found in lib/whos_got_dirt/requests/entity/open_corporates.rb and 1 other location - About 35 mins to fix
        lib/whos_got_dirt/requests/entity/corp_watch.rb on lines 96..99

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 34.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                  input['contact_details'] && input['contact_details'].each do |contact_detail|
                    if contact_detail['type'] == 'address' && (contact_detail['value'] || contact_detail['value~='])
                      output['raw_address'] = contact_detail['value'] || contact_detail['value~=']
                    end
        Severity: Minor
        Found in lib/whos_got_dirt/requests/entity/corp_watch.rb and 1 other location - About 35 mins to fix
        lib/whos_got_dirt/requests/entity/open_corporates.rb on lines 84..87

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 34.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Method validate! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def validate!(opts = {})
              # The code assumes that processing errors in reverse avoids re-indexing
              # issues when deleting items from arrays. If this assumption is invalid,
              # we can delete items one at a time and re-validate using this skeleton:
              #
        Severity: Minor
        Found in lib/whos_got_dirt/result.rb - About 25 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

        Method convert has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

                def convert
                  equal('per_page', 'limit', default: input['open_corporates_api_key'] && 100) # default 30, maximum 100
                  equal('page', 'page')
        
                  input['subject'] && input['subject'].each do |subject|
        Severity: Minor
        Found in lib/whos_got_dirt/requests/relation/open_corporates.rb - About 25 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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                def to_a
                  list = parsed_body['Data']['Lists']['List']
                  if Hash === list
                    list = [list]
                  end
        Severity: Minor
        Found in lib/whos_got_dirt/responses/list/little_sis.rb and 1 other location - About 25 mins to fix
        lib/whos_got_dirt/responses/entity/little_sis.rb on lines 58..64

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 29.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                def to_a
                  list = parsed_body['Data']['Entities']['Entity']
                  if Hash === list
                    list = [list]
                  end
        Severity: Minor
        Found in lib/whos_got_dirt/responses/entity/little_sis.rb and 1 other location - About 25 mins to fix
        lib/whos_got_dirt/responses/list/little_sis.rb on lines 34..40

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 29.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Severity
        Category
        Status
        Source
        Language