postmodern/command_kit.rb

View on GitHub

Showing 27 of 32 total issues

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

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

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

    def self.camelize(name)
      scanner    = StringScanner.new(name.to_s)
      new_string = String.new

      until scanner.eos?
Severity: Minor
Found in lib/command_kit/inflector.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 open has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def open(path,mode='r',&block)
      if path == '-'
        io = case mode
             when /[wa]/ then stdout
             else             stdin
Severity: Minor
Found in lib/command_kit/open.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 xdg_namespace has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def xdg_namespace(new_namespace=nil)
        if new_namespace
          @xdg_namespace = new_namespace.to_s
        else
          @xdg_namespace || if superclass.kind_of?(ClassMethods)
Severity: Minor
Found in lib/command_kit/xdg.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 os has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def os
        if    RUBY_PLATFORM.include?('linux')   then :linux
        elsif RUBY_PLATFORM.include?('darwin')  then :macos
        elsif RUBY_PLATFORM.include?('freebsd') then :freebsd
        elsif RUBY_PLATFORM.include?('openbsd') then :openbsd
Severity: Minor
Found in lib/command_kit/os.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 help_commands has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def help_commands
      unless self.class.commands.empty?
        puts
        puts "Commands:"

Severity: Minor
Found in lib/command_kit/commands.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