funkwerk/gherkin_lint

View on GitHub
lib/gherkin_lint/linter.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Class Linter has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Linter
    attr_reader :issues

    def self.descendants
      ObjectSpace.each_object(::Class).select { |klass| klass < self }
Severity: Minor
Found in lib/gherkin_lint/linter.rb - About 2 hrs to fix

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

        def elements
          @files.each do |file, content|
            feature = content[:feature]
            next if feature.nil?
            next unless feature.key? :children
    Severity: Minor
    Found in lib/gherkin_lint/linter.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 suppress_tags has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def suppress_tags(data, tags)
          return data.map { |item| suppress_tags(item, tags) } if data.class == Array
          return data unless data.class == Hash
          result = {}
    
    
    Severity: Minor
    Found in lib/gherkin_lint/linter.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 filled_scenarios has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def filled_scenarios
          scenarios do |file, feature, scenario|
            next unless scenario.include? :steps
            next if scenario[:steps].empty?
            yield(file, feature, scenario)
    Severity: Minor
    Found in lib/gherkin_lint/linter.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 filter_tag has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def filter_tag(data, tag)
          return data.reject { |item| tag?(item, tag) }.map { |item| filter_tag(item, tag) } if data.class == Array
          return {} if (data.class == Hash) && (data.include? :feature) && tag?(data[:feature], tag)
          return data unless data.respond_to? :each_pair
          result = {}
    Severity: Minor
    Found in lib/gherkin_lint/linter.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 line has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def line(feature, scenario, step)
          line = feature.nil? ? nil : feature[:location][:line]
          line = scenario[:location][:line] unless scenario.nil?
          line = step[:location][:line] unless step.nil?
          line
    Severity: Minor
    Found in lib/gherkin_lint/linter.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 reference has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def reference(file, feature = nil, scenario = nil, step = nil)
          return file if feature.nil? || feature[:name].empty?
          result = "#{file} (#{line(feature, scenario, step)}): #{feature[:name]}"
          result += ".#{scenario[:name]}" unless scenario.nil? || scenario[:name].empty?
          result += " step: #{step[:text]}" unless step.nil?
    Severity: Minor
    Found in lib/gherkin_lint/linter.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

    There are no issues that match your filters.

    Category
    Status