erikhuda/thor

View on GitHub

Showing 75 of 83 total issues

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

      def say_status(behavior, warning: nil, color: nil)
        status = if behavior == :invoke
          if flag == /\A/
            :prepend
          elsif flag == /\z/
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 terminal_width has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def terminal_width
        result = if ENV["THOR_COLUMNS"]
          ENV["THOR_COLUMNS"].to_i
        else
          unix? ? dynamic_width : DEFAULT_TERMINAL_WIDTH
Severity: Minor
Found in lib/thor/shell/basic.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 display_klasses has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def display_klasses(with_modules = false, show_internal = false, klasses = Thor::Base.subclasses)
    klasses -= [Thor, Thor::Runner, Thor::Group] unless show_internal

    raise Error, "No Thor commands available" if klasses.empty?
    show_modules if with_modules && !thor_yaml.empty?
Severity: Minor
Found in lib/thor/runner.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 parse_string has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_string(name)
      if no_or_skip?(name)
        nil
      else
        value = shift
Severity: Minor
Found in lib/thor/parser/arguments.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 register has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def register(klass, subcommand_name, usage, description, options = {})
Severity: Minor
Found in lib/thor.rb - About 35 mins to fix

    Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def initialize(name, description, long_description, usage, options = nil)
    Severity: Minor
    Found in lib/thor/command.rb - About 35 mins to fix

      Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def initialize(base, source, destination = nil, config = {}, &block)
      Severity: Minor
      Found in lib/thor/actions/directory.rb - About 35 mins to fix

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

            def find_in_source_paths(file)
              possible_files = [file, file + TEMPLATE_EXTNAME]
              relative_root = relative_to_original_destination_root(destination_root, false)
        
              source_paths.each do |source|
        Severity: Minor
        Found in lib/thor/actions.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 print_in_columns has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def print_in_columns(array)
                return if array.empty?
                colwidth = (array.map { |el| el.to_s.size }.max || 0) + 2
                array.each_with_index do |value, index|
                  # Don't output trailing spaces when printing the last column
        Severity: Minor
        Found in lib/thor/shell/basic.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize(args = [], local_options = {}, config = {})
              parse_options = self.class.class_options
        
              # The start method splits inbound arguments at the first argument
              # that looks like an option (starts with - or --). It then calls
        Severity: Minor
        Found in lib/thor/base.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 say_status has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def say_status(status, message, log_status = true)
                return if quiet? || log_status == false
                spaces = "  " * (padding + 1)
                color  = log_status.is_a?(Symbol) ? log_status : :green
        
        
        Severity: Minor
        Found in lib/thor/shell/basic.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 invoke_from_option has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def invoke_from_option(*names, &block)
              options = names.last.is_a?(Hash) ? names.pop : {}
              verbose = options.fetch(:verbose, :white)
        
              names.each do |name|
        Severity: Minor
        Found in lib/thor/group.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 parse_boolean has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def parse_boolean(switch)
              if current_is_value?
                if ["true", "TRUE", "t", "T", true].include?(peek)
                  shift
                  true
        Severity: Minor
        Found in lib/thor/parser/options.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 set_color has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def set_color(string, *colors)
                if colors.all? { |color| color.is_a?(Symbol) || color.is_a?(String) }
                  html_colors = colors.map { |color| lookup_color(color) }
                  "<span style=\"#{html_colors.join('; ')};\">#{Thor::Util.escape_html(string)}</span>"
                else
        Severity: Minor
        Found in lib/thor/shell/html.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 force_or_skip_or_conflict has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def force_or_skip_or_conflict(force, skip, &block)
                if force
                  say_status :force, :yellow
                  yield unless pretend?
                elsif skip
        Severity: Minor
        Found in lib/thor/actions/create_file.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 desc has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def desc(usage, description, options = {})
              if options[:for]
                command = find_and_refresh_command(options[:for])
                command.usage = usage             if usage
                command.description = description if description
        Severity: Minor
        Found in lib/thor.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 relative_to_original_destination_root has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def relative_to_original_destination_root(path, remove_dot = true)
              root = @destination_stack[0]
              if path.start_with?(root) && [File::SEPARATOR, File::ALT_SEPARATOR, nil, ''].include?(path[root.size..root.size])
                path = path.dup
                path[0...root.size] = '.'
        Severity: Minor
        Found in lib/thor/actions.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 invoke has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def invoke(name = nil, *args)
              if name.nil?
                warn "[Thor] Calling invoke() without argument is deprecated. Please use invoke_all instead.\n#{caller.join("\n")}"
                return invoke_all
              end
        Severity: Minor
        Found in lib/thor/invocation.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 normalize_command_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def normalize_command_name(meth) #:nodoc:
              return default_command.to_s.tr("-", "_") unless meth
        
              possibilities = find_command_possibilities(meth)
              raise AmbiguousTaskError, "Ambiguous command #{meth} matches [#{possibilities.join(', ')}]" if possibilities.size > 1
        Severity: Minor
        Found in lib/thor.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 invoke! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def invoke!
                invoke_with_conflict_check do
                  require "fileutils"
                  FileUtils.mkdir_p(File.dirname(destination))
                  # Create a symlink by default
        Severity: Minor
        Found in lib/thor/actions/create_link.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

        Severity
        Category
        Status
        Source
        Language