erikhuda/thor

View on GitHub

Showing 75 of 83 total issues

Method usage has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def usage(padding = 0)
      sample = if banner && !banner.to_s.empty?
        "#{switch_name}=#{banner}".dup
      else
        switch_name
Severity: Minor
Found in lib/thor/parser/option.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 file_collision has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def file_collision(destination)
        return true if @always_force
        options = block_given? ? "[Ynaqdhm]" : "[Ynaqh]"

        loop do
Severity: Minor
Found in lib/thor/shell/basic.rb - About 1 hr to fix

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

        def validate_default_type!
          default_type = case @default
          when nil
            return
          when TrueClass, FalseClass
    Severity: Minor
    Found in lib/thor/parser/option.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 print_wrapped has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

          def print_wrapped(message, options = {})
            indent = options[:indent] || 0
            width = terminal_width - indent
            paras = message.split("\n\n")
    
    
    Severity: Minor
    Found in lib/thor/shell/basic.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 parse_peek has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_peek(switch, option)
          if parsing_options? && (current_is_switch_formatted? || last?)
            if option.boolean?
              # No problem for boolean types
            elsif no_or_skip?(switch)
    Severity: Minor
    Found in lib/thor/parser/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 set_color has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def set_color(string, *colors)
            if colors.compact.empty? || !can_display_colors?
              string
            elsif colors.all? { |color| color.is_a?(Symbol) || color.is_a?(String) }
              ansi_colors = colors.map { |color| lookup_color(color) }
    Severity: Minor
    Found in lib/thor/shell/color.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 map has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def map(mappings = nil, **kw)
          @map ||= from_superclass(:map, {})
    
          if mappings && !kw.empty?
            mappings = kw.merge!(mappings)
    Severity: Minor
    Found in lib/thor.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 run has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def run(command, config = {})
          return unless behavior == :invoke
    
          destination = relative_to_original_destination_root(destination_root, false)
          desc = "#{command} from #{destination.inspect}"
    Severity: Minor
    Found in lib/thor/actions.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 template has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def template(source, *args, &block)
          config = args.last.is_a?(Hash) ? args.pop : {}
          destination = args.first || source.sub(/#{TEMPLATE_EXTNAME}$/, "")
    
          source  = File.expand_path(find_in_source_paths(source.to_s))
    Severity: Minor
    Found in lib/thor/actions/file_manipulation.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 printable_commands has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def printable_commands(all = true, subcommand = false)
          (all ? all_commands : commands).map do |_, command|
            next if command.hidden?
            item = []
            item << banner(command, false, subcommand)
    Severity: Minor
    Found in lib/thor.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 dispatch has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def dispatch(meth, given_args, given_opts, config) #:nodoc: # rubocop:disable MethodLength
          meth ||= retrieve_command_name(given_args)
          command = all_commands[normalize_command_name(meth)]
    
          if !command && config[:invoked_via_subcommand]
    Severity: Minor
    Found in lib/thor.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 parse_numeric has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_numeric(name)
          return shift if peek.is_a?(Numeric)
    
          unless peek =~ NUMERIC && $& == peek
            raise MalformattedArgumentError, "Expected numeric value for '#{name}'; got #{peek.inspect}"
    Severity: Minor
    Found in lib/thor/parser/arguments.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 invoke! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def invoke!
            content = if @behavior == :after
              '\0' + replacement
            else
              replacement + '\0'
    Severity: Minor
    Found in lib/thor/actions/inject_into_file.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 thor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def thor(command, *args)
          config  = args.last.is_a?(Hash) ? args.pop : {}
          verbose = config.key?(:verbose) ? config.delete(:verbose) : true
          pretend = config.key?(:pretend) ? config.delete(:pretend) : false
          capture = config.key?(:capture) ? config.delete(:capture) : false
    Severity: Minor
    Found in lib/thor/actions.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 check_unknown_options? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_unknown_options?(config) #:nodoc:
          options = check_unknown_options
          return false unless options
    
          command = config[:current_command]
    Severity: Minor
    Found in lib/thor.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 deeply nested control flow statements.
    Open

                @extra << shift while peek
    Severity: Major
    Found in lib/thor/parser/options.rb - About 45 mins to fix

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

            def invoke_with_conflict_check(&block)
              if exists?
                on_conflict_behavior(&block)
              else
                yield unless pretend?
      Severity: Minor
      Found in lib/thor/actions/empty_directory.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 deeply nested control flow statements.
      Open

                elsif match
                  @extra << shifted
                  @extra << shift while peek && peek !~ /^-/
                else
                  @extra << shifted
      Severity: Major
      Found in lib/thor/parser/options.rb - About 45 mins to fix

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

              def argument(name, options = {})
                is_thor_reserved_word?(name, :argument)
                no_commands { attr_accessor name }
        
                required = if options.key?(:optional)
        Severity: Minor
        Found in lib/thor/base.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 start has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def start(given_args = ARGV, config = {})
                config[:shell] ||= Thor::Base.shell.new
                dispatch(nil, given_args.dup, nil, config)
              rescue Thor::Error => e
                config[:debug] || ENV["THOR_DEBUG"] == "1" ? (raise e) : config[:shell].error(e.message)
        Severity: Minor
        Found in lib/thor/base.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

        Severity
        Category
        Status
        Source
        Language