tily/barthes

View on GitHub

Showing 20 of 20 total issues

Method action has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

        def action(action)
            begin
                @env.update(action['env']) if action['env']
                params = evaluate_params(action['params'])

Severity: Minor
Found in lib/barthes/action.rb - About 3 hrs 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 walk_json has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

            def walk_json(json, parents=[]) 
                case json.first
                when 'feature'
                    if json.last.class == Array
                        @xml.testsuite(name: json[1], tests: json.last.size) do
Severity: Minor
Found in lib/barthes/reporter/junit_xml.rb - About 2 hrs 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

        when 'jmespath_size'
            size = jmespath(response, expectation['jmespath']).size
            if expectation['method'].nil? || expectation['method'] == 'eq'
                result = (size == expectation['value'])
            elsif expectation['method'] == 'gt'
Severity: Major
Found in lib/barthes/client/ace_json4.rb and 1 other location - About 2 hrs to fix
lib/barthes/client/httparty.rb on lines 44..57

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 84.

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

                when 'xpath_size'
                    size = xpath(response, expectation['xpath']).size
                    if expectation['method'].nil? || expectation['method'] == 'eq'
                        result = (size == expectation['value'])
                    elsif expectation['method'] == 'gt'
Severity: Major
Found in lib/barthes/client/httparty.rb and 1 other location - About 2 hrs to fix
lib/barthes/client/ace_json4.rb on lines 26..39

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 84.

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 walk_json has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

            def walk_json(json, parents=[]) 
                case json.first
                when 'feature'
                    if json.last.class == Array
                        @xml.testsuite(name: json[1], tests: json.last.size) do
Severity: Major
Found in lib/barthes/reporter/junit_xml.rb - About 2 hrs to fix

    Method action has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def action(action)
                begin
                    @env.update(action['env']) if action['env']
                    params = evaluate_params(action['params'])
    
    
    Severity: Minor
    Found in lib/barthes/action.rb - About 1 hr to fix

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

                  def after_action(name, action, scenarios)
                      if Barthes::Config[:quiet] == 0 && Barthes::Config[:dryrun] == 0
                          puts indent scenarios.size + 1, "request:"
                          puts indent scenarios.size + 2, JSON.pretty_generate(action['request']) if action['request']
                          if %w(success failure).include?(action['status']) && action['response']
      Severity: Minor
      Found in lib/barthes/reporter/default.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 compare has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

                  def compare(response, expectation)
                      result = nil
                      case expectation['type']
                      when 'response_code'
                          result = response.code == expectation['value']
      Severity: Minor
      Found in lib/barthes/client/httparty.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 compare has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def compare(response, expectation)
              result = nil
              case expectation['type']
              when 'response_code'
                  result = response.code == expectation['value']
      Severity: Minor
      Found in lib/barthes/client/ace_json4.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 compare has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  def compare(response, expectation)
                      result = nil
                      case expectation['type']
                      when 'response_code'
                          result = response.code == expectation['value']
      Severity: Minor
      Found in lib/barthes/client/httparty.rb - About 1 hr to fix

        Method compare has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def compare(response, expectation)
                result = nil
                case expectation['type']
                when 'response_code'
                    result = response.code == expectation['value']
        Severity: Minor
        Found in lib/barthes/client/ace_json4.rb - About 1 hr to fix

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

                  def walk_json(json, scenarios)
                      if json.class == Array
                          case json.first
                          when 'scenario'
                              handle_scenario(json, scenarios)
          Severity: Minor
          Found in lib/barthes/runner.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 after_action has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                      def after_action(name, action, scenarios)
                          if Barthes::Config[:quiet] == 0 && Barthes::Config[:dryrun] == 0
                              puts indent scenarios.size + 1, "request:"
                              puts indent scenarios.size + 2, JSON.pretty_generate(action['request']) if action['request']
                              if %w(success failure).include?(action['status']) && action['response']
          Severity: Minor
          Found in lib/barthes/reporter/default.rb - About 1 hr to fix

            Method handle_action has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                    def handle_action(action, scenarios)
                        return if @failed
                        name, content = action[1], action.last
                        env = @env.dup
                        env.update(content['env']) if content['env']
            Severity: Minor
            Found in lib/barthes/runner.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

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

                                if expectation['method'].nil? || expectation['method'] == 'eq'
                                    result = (text == expectation['value'])
                                            elsif expectation['method'] == 'regexp'
                                    result = !(text.match Regexp.new(expectation['value'])).nil?
                                elsif expectation['method'] == 'ne'
            Severity: Minor
            Found in lib/barthes/client/httparty.rb and 1 other location - About 55 mins to fix
            lib/barthes/client/ace_json4.rb on lines 18..24

            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 45.

            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

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

                        if expectation['method'].nil? || expectation['method'] == 'eq'
                            result = (text == expectation['value'])
                        elsif expectation['method'] == 'regexp'
                            result = !(text.match Regexp.new(expectation['value'])).nil?
                        elsif expectation['method'] == 'ne'
            Severity: Minor
            Found in lib/barthes/client/ace_json4.rb and 1 other location - About 55 mins to fix
            lib/barthes/client/httparty.rb on lines 36..42

            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 45.

            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 tagged? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                    def tagged?(env)
                        return true if Barthes::Config[:tags].nil? && Barthes::Config[:'no-tags'].nil?
                        tags = env['tags'] || []
                        if Barthes::Config[:tags].nil?
                            if (Barthes::Config[:'no-tags'] & tags).size > 0
            Severity: Minor
            Found in lib/barthes/runner.rb - About 45 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 after_run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                        def after_run(features)
                            @count = Hash.new(0)
                            walk_json(features)
                            puts '-' * 80
                            puts [
            Severity: Minor
            Found in lib/barthes/reporter/default.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 expand_paths has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def expand_paths(paths, suffix)
                        files = []
                        if paths.empty?
                            files += Dir["./**/*#{suffix}"]
                        else
            Severity: Minor
            Found in lib/barthes/runner.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def initialize
                        @reporters = []
                        if Barthes::Config[:reporters]
                            Barthes::Config[:reporters].each do |reporter|
                                if reporter.match(/^(.+)(\{.*\})$/)
            Severity: Minor
            Found in lib/barthes/reporter.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

            Severity
            Category
            Status
            Source
            Language