r-cochran/cuke_sniffer

View on GitHub

Showing 26 of 26 total issues

File rule_config.rb has 478 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module CukeSniffer

  # Contains the rules and various scores used in evaluating objects
  module RuleConfig

Severity: Minor
Found in lib/cuke_sniffer/rule_config.rb - About 7 hrs to fix

    Method detect_nested_steps has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        def detect_nested_steps
          multi_line_step_flag = false
          counter = 1
          @code.each do |line|
            regex = nil
    Severity: Minor
    Found in lib/cuke_sniffer/step_definition.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

    Class CLI has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class CLI
        include CukeSniffer::Constants
        include CukeSniffer::RuleConfig
        include ROXML
    
    
    Severity: Minor
    Found in lib/cuke_sniffer/cli.rb - About 3 hrs to fix

      Method split_feature has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          def split_feature(file_name, feature_lines)
            index = 0
            until index >= feature_lines.length or feature_lines[index].match /Feature:\s*(?<name>.*)/
              update_tag_list(feature_lines[index])
              index += 1
      Severity: Minor
      Found in lib/cuke_sniffer/feature.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

      Method detect_nested_steps has 49 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def detect_nested_steps
            multi_line_step_flag = false
            counter = 1
            @code.each do |line|
              regex = nil
      Severity: Minor
      Found in lib/cuke_sniffer/step_definition.rb - About 1 hr to fix

        Method output_junit_xml has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def self.output_junit_xml(cuke_sniffer, file_name = DEFAULT_OUTPUT_FILE_NAME)
              file_name = file_name + ".xml" unless file_name =~ /\.xml$/
              results = {}
              failures = 0
              suits={}
        Severity: Minor
        Found in lib/cuke_sniffer/formatter.rb - About 1 hr to fix

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

              def self.output_junit_xml(cuke_sniffer, file_name = DEFAULT_OUTPUT_FILE_NAME)
                file_name = file_name + ".xml" unless file_name =~ /\.xml$/
                results = {}
                failures = 0
                suits={}
          Severity: Minor
          Found in lib/cuke_sniffer/formatter.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

          Function changeRuleStatus has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

                  changeRuleStatus: function(){
                      $(document).on("click", ".rule input[type='checkbox']", function(){
                          var enabled = $(this).is(":checked"),
                              $rule = $(this).closest(".rule"),
                              phrase = $rule.find("[data-phrase]").html(),
          Severity: Minor
          Found in lib/cuke_sniffer/js/cuke_sniffer.js - 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 split_feature has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def split_feature(file_name, feature_lines)
                index = 0
                until index >= feature_lines.length or feature_lines[index].match /Feature:\s*(?<name>.*)/
                  update_tag_list(feature_lines[index])
                  index += 1
          Severity: Minor
          Found in lib/cuke_sniffer/feature.rb - About 1 hr to fix

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

                    _bindCollapseAll: function(){
                        $(document).on("click", "[collapse]", function(){
                            $(this).closest(".panel-body").find(".details").hide();
                        });
                    },
            Severity: Major
            Found in lib/cuke_sniffer/js/cuke_sniffer.js and 1 other location - About 1 hr to fix
            lib/cuke_sniffer/js/cuke_sniffer.js on lines 69..73

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

            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

                    _bindExpandAll: function(){
                        $(document).on("click", "[expand]", function(){
                            $(this).closest(".panel-body").find(".details").show();
                        });
                    },
            Severity: Major
            Found in lib/cuke_sniffer/js/cuke_sniffer.js and 1 other location - About 1 hr to fix
            lib/cuke_sniffer/js/cuke_sniffer.js on lines 80..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 62.

            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

            Function changeRuleStatus has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    changeRuleStatus: function(){
                        $(document).on("click", ".rule input[type='checkbox']", function(){
                            var enabled = $(this).is(":checked"),
                                $rule = $(this).closest(".rule"),
                                phrase = $rule.find("[data-phrase]").html(),
            Severity: Minor
            Found in lib/cuke_sniffer/js/cuke_sniffer.js - About 1 hr to fix

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

                  def judge_object(object, type)
                    @rules.each do |rule|
                      fail "No targets for rule: #{rule.phrase}" if rule.targets.nil? or rule.targets.empty?
                      next unless rule.targets.include? type and rule.enabled
                      if rule.reason.(object, rule) == true
              Severity: Minor
              Found in lib/cuke_sniffer/rules_evaluator.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 build_object_for_extension_from_file has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def build_object_for_extension_from_file(file_name, regex, cuke_sniffer_class)
                    file_lines = IO.readlines(file_name)
              
                    counter = 0
                    code = []
              Severity: Minor
              Found in lib/cuke_sniffer/cli.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

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

                      :small_sleep => {
                          :enabled => true,
                          :phrase => "Small sleeps used. Use a wait_until like method.",
                          :score => INFO,
                          :max => 2,
              Severity: Minor
              Found in lib/cuke_sniffer/rule_config.rb and 1 other location - About 55 mins to fix
              lib/cuke_sniffer/rule_config.rb on lines 468..478

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

              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

                      :large_sleep => {
                          :enabled => true,
                          :phrase => "Large sleeps used. Use a wait_until like method.",
                          :score => INFO,
                          :min => 2,
              Severity: Minor
              Found in lib/cuke_sniffer/rule_config.rb and 1 other location - About 55 mins to fix
              lib/cuke_sniffer/rule_config.rb on lines 454..464

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

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

                  def self.assess_rule_target_list(rule_target_list, type)
                    assessment_hash = initialize_assessment_hash(rule_target_list, type)
                    rule_target_list.each do |rule_target|
                      score = rule_target.score
                      assessment_hash[:total_score] += score
              Severity: Minor
              Found in lib/cuke_sniffer/summary_helper.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 extract_inline_tables has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def extract_inline_tables(scenario_body)
                    index = 0
                    while index < scenario_body.size
                      if scenario_body[index] =~ /^\|.*\|/
                        start_index = index
              Severity: Minor
              Found in lib/cuke_sniffer/scenario.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

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

                  def self.extract_steps_from_features(features)
                    steps = {}
                    features.each do |feature|
                      steps.merge! extract_scenario_steps(feature.background) unless feature.background.nil?
                      feature.scenarios.each do |scenario|
              Severity: Minor
              Found in lib/cuke_sniffer/cuke_sniffer_helper.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

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

                  def self.catalog_possible_dead_steps(step_definitions, steps_with_expressions)
                    step_definitions.each do |step_definition|
                      next unless step_definition.calls.empty?
                      regex_as_string = step_definition.regex.to_s.gsub(/\(\?-mix:\^?/, "").gsub(/\$\)$/, "")
                      steps_with_expressions.each do |step_location, step_value|
              Severity: Minor
              Found in lib/cuke_sniffer/cuke_sniffer_helper.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

              Severity
              Category
              Status
              Source
              Language