dgollahon/rspectre

View on GitHub

Showing 4 of 7 total issues

Method initialize has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def initialize(*names) # rubocop:disable Lint/MissingSuper
      raise 'Specify at least one keyword name!' if names.empty?

      names.each do |name|
        next if /\A\w+\z/.match?(name)
Severity: Minor
Found in lib/rspectre/keyword_struct.rb - About 1 hr to fix

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

        def self.register(selector, locations)
          location = locations.first
    
          file = File.realpath(location.path)
          line = location.lineno
    Severity: Minor
    Found in lib/rspectre/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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize(*names) # rubocop:disable Lint/MissingSuper
          raise 'Specify at least one keyword name!' if names.empty?
    
          names.each do |name|
            next if /\A\w+\z/.match?(name)
    Severity: Minor
    Found in lib/rspectre/keyword_struct.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 range_end has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def range_end(node)
          location = node.location.expression
    
          last_line    = location.last_line
          end_location = location.end
    Severity: Minor
    Found in lib/rspectre/auto_corrector.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