postmodern/command_kit.rb

View on GitHub

Showing 29 of 29 total issues

Method initialize has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(package_manager: nil, **kwargs)
      super(**kwargs)

      @package_manager = package_manager || begin
        if macos?
Severity: Minor
Found in lib/command_kit/package_manager.rb - About 4 hrs 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 96 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def run
    header = ['A', 'B', 'C']
    table = [
      ['AAAA', 'BBBB', 'CCCC'],
      ['AAAA', 'BBBB', 'CCCC'],
Severity: Major
Found in examples/printing/tables.rb - About 3 hrs to fix

    Method run has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

          def run(name=nil)
            if name
              unless ITEMS.include?(name)
                print_error "unknown item: #{name}"
                exit(1)
    Severity: Minor
    Found in examples/subcommands/cli/update.rb - About 2 hrs 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

    File colors.rb has 260 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require_relative 'stdio'
    require_relative 'env'
    
    module CommandKit
      #
    Severity: Minor
    Found in lib/command_kit/colors.rb - About 2 hrs to fix

      Method underscore has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.underscore(name)
            scanner    = StringScanner.new(name.to_s)
            new_string = String.new
      
            until scanner.eos?
      Severity: Minor
      Found in lib/command_kit/inflector.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 install_packages has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def install_packages(*packages, yes: false,
                                          apt: nil,
                                          brew: nil,
                                          dnf: nil,
                                          pacman: nil,
      Severity: Minor
      Found in lib/command_kit/package_manager.rb - About 1 hr to fix

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

                def format(&block)
                  yield format_top_border if @style.border
        
                  separator_row = if @table.header? || @style.separate_rows?
                                    format_separator_row
        Severity: Minor
        Found in lib/command_kit/printing/tables/table_formatter.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 help_arguments has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def help_arguments
              unless (arguments = self.class.arguments).empty?
                puts
                puts 'Arguments:'
        
        
        Severity: Minor
        Found in lib/command_kit/arguments.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 ask has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def ask(prompt, default: nil, required: false)
              prompt = prompt.chomp
              prompt << " [#{default}]" if default
              prompt << ": "
        
        
        Severity: Minor
        Found in lib/command_kit/interactive.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 command has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def command(name)
              unless (command_class = self.class.get_command(name))
                return
              end
        
        
        Severity: Minor
        Found in lib/command_kit/commands.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 install_packages has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def install_packages(*packages, yes: false,
                                            apt: nil,
                                            brew: nil,
                                            dnf: nil,
                                            pacman: nil,
        Severity: Minor
        Found in lib/command_kit/package_manager.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 initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize(**kwargs)
              super(**kwargs)
        
              @open_command = if macos?
                                'open'
        Severity: Minor
        Found in lib/command_kit/open_app.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 help has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def help
                if stdout.tty?
                  if self.class.man_dir
                    status = help_man
        
        
        Severity: Minor
        Found in lib/command_kit/help/man.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 define_option has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def define_option(option)
              unless (default_value = option.default_value).nil?
                @options[option.name] = default_value
              end
        
        
        Severity: Minor
        Found in lib/command_kit/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

        Avoid deeply nested control flow statements.
        Open

                  :pkg_add if command_installed?('pkg_add')
        Severity: Major
        Found in lib/command_kit/package_manager.rb - About 45 mins to fix

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

                def run(command=nil)
                  case command
                  when nil
                    parent_command.help
                  else
          Severity: Minor
          Found in lib/command_kit/commands/help.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

                      :apt if command_installed?('apt')
          Severity: Major
          Found in lib/command_kit/package_manager.rb - About 45 mins to fix

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

                  def normalize_completion_file(path, type: :bash)
                    ext  = File.extname(path)
                    file = File.basename(path,ext)
            
                    case [shell_type, type]
            Severity: Minor
            Found in lib/command_kit/completion/install.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 suse_linux?
                        :zypper if command_installed?('zypper')
                      elsif arch_linux?
                        :pacman if command_installed?('pacman')
            Severity: Major
            Found in lib/command_kit/package_manager.rb - About 45 mins to fix

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

                    def initialize(**kwargs)
                      super(**kwargs)
              
                      @completions_dir = case shell_type
                                         when :bash
              Severity: Minor
              Found in lib/command_kit/completion/install.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