sensu-plugins/sensu-plugins-cucumber

View on GitHub

Showing 15 of 15 total issues

File check-cucumber.rb has 385 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'sensu-plugin/check/cli'
require 'optparse'
require 'timeout'
require 'json'
require 'yaml'
Severity: Minor
Found in bin/check-cucumber.rb - About 5 hrs to fix

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

      def run
        return unless config_is_valid?
    
        result = nil
    
    
    Severity: Minor
    Found in bin/check-cucumber.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 run has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def run
        return unless config_is_valid?
    
        result = nil
    
    
    Severity: Major
    Found in bin/check-cucumber.rb - About 2 hrs to fix

      Method generate_metrics_from_scenario has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def generate_metrics_from_scenario(feature, scenario, scenario_status, utc_timestamp)
          metrics = []
      
          if scenario_status == :passed
            scenario_duration = 0
      Severity: Minor
      Found in bin/check-cucumber.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 config_is_valid? has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def config_is_valid?
          if config[:name].nil?
            unknown_error 'No name specified'
            return false
          end
      Severity: Minor
      Found in bin/check-cucumber.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 config_is_valid? has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def config_is_valid?
          if config[:name].nil?
            unknown_error 'No name specified'
            return false
          end
      Severity: Minor
      Found in bin/check-cucumber.rb - About 1 hr to fix

        Method generate_sensu_event has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def generate_sensu_event(event_name, feature, scenario, scenario_status)
            scenario_clone = deep_dup(scenario)
            remove_attachments_from_scenario(scenario_clone) unless config[:attachments]
            feature_clone = deep_dup(feature)
            feature_clone[:elements] = [scenario_clone]
        Severity: Minor
        Found in bin/check-cucumber.rb - About 1 hr to fix

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

            def generate_metrics_from_scenario(feature, scenario, scenario_status, utc_timestamp)
              metrics = []
          
              if scenario_status == :passed
                scenario_duration = 0
          Severity: Minor
          Found in bin/check-cucumber.rb - About 1 hr to fix

            Method generate_sensu_event has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def generate_sensu_event(event_name, feature, scenario, scenario_status)
                scenario_clone = deep_dup(scenario)
                remove_attachments_from_scenario(scenario_clone) unless config[:attachments]
                feature_clone = deep_dup(feature)
                feature_clone[:elements] = [scenario_clone]
            Severity: Minor
            Found in bin/check-cucumber.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

            Avoid too many return statements within this method.
            Open

                  return false
            Severity: Major
            Found in bin/check-cucumber.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    return false
              Severity: Major
              Found in bin/check-cucumber.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                      return false
                Severity: Major
                Found in bin/check-cucumber.rb - About 30 mins to fix

                  Function exports has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  module.exports = function() {
                    this.Given(/^a passing pre-condition$/, function(callback) {
                      if (this.isDryRun()) { return callback(); }
                  
                      callback();
                  Severity: Minor
                  Found in bin/cucumber-example/features/step_definitions/passing.js - 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 get_scenario_status has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def get_scenario_status(scenario)
                      scenario_status = :passed
                  
                      # #YELLOW
                      Array(scenario[:steps]).each do |step|
                  Severity: Minor
                  Found in bin/check-cucumber.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 get_output_for_scenario has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def get_output_for_scenario(scenario, scenario_status)
                      steps_output = []
                  
                      Array(scenario[:steps]).each_with_index do |step, index|
                        has_result = step.key?(:result)
                  Severity: Minor
                  Found in bin/check-cucumber.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