rubocop-hq/rubocop

View on GitHub
lib/rubocop/options.rb

Summary

Maintainability
D
1 day
Test Coverage
A
99%

File options.rb has 519 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'optparse'
require_relative 'arguments_env'
require_relative 'arguments_file'

module RuboCop
Severity: Major
Found in lib/rubocop/options.rb - About 1 day to fix

    Class Options has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Options
        E_STDIN_NO_PATH = '-s/--stdin requires exactly one path, relative to the ' \
                          'root of the project. RuboCop will use this path to determine which ' \
                          'cops are enabled (via eg. Include/Exclude), and so that certain cops ' \
                          'like Naming/FileName can be checked.'
    Severity: Minor
    Found in lib/rubocop/options.rb - About 2 hrs to fix

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

            def validate_cop_list(names)
              return unless names
      
              cop_names = Cop::Registry.global.names
              departments = Cop::Registry.global.departments.map(&:to_s)
      Severity: Minor
      Found in lib/rubocop/options.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 add_check_options has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def add_check_options(opts) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
            section(opts, 'Basic Options') do # rubocop:disable Metrics/BlockLength
              option(opts, '-l', '--lint') do
                @options[:only] ||= []
                @options[:only] << 'Lint'
      Severity: Minor
      Found in lib/rubocop/options.rb - About 1 hr to fix

        Method add_cop_selection_csv_option has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def add_cop_selection_csv_option(option, opts)
              option(opts, "--#{option} [COP1,COP2,...]") do |list|
                unless list
                  message = "--#{option} argument should be [COP1,COP2,...]."
        
        
        Severity: Minor
        Found in lib/rubocop/options.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

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

            def add_additional_modes(opts)
              section(opts, 'Additional Modes') do
                option(opts, '-L', '--list-target-files')
                option(opts, '--show-cops [COP1,COP2,...]') do |list|
                  @options[:show_cops] = list.nil? ? [] : list.split(',')
        Severity: Minor
        Found in lib/rubocop/options.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

        There are no issues that match your filters.

        Category
        Status