timcolonel/clin

View on GitHub

Showing 8 of 8 total issues

Method choice_help has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def choice_help(choices, allow_initials: false)
    used_initials = Set.new
    Clin::Text.new do |t|
      t.line 'Choose from:'
      t.table(indent: 2, border: false, separate_blank: false) do |m|
Severity: Minor
Found in lib/clin/shell_interaction/choose.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(statement, choices, default: nil, allow_initials: false)
    choices = convert_choices(choices)
    question = prepare_question(statement, choices, default: default, initials: allow_initials)
    loop do
      answer = @shell.ask(question, default: default, autocomplete: choices.keys)
Severity: Minor
Found in lib/clin/shell_interaction/choose.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 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def parse(argv)
    return handle_empty if argv.empty?
    if @multiple
      ensure_fixed(argv) unless @variable
      [argv, []]
Severity: Minor
Found in lib/clin/argument.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 choice_help has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def choice_help(choices, start_index)
    Clin::Text::Table.new(border: false, col_delim: ' ') do |t|
      i = start_index
      choices.each do |key, description|
        key = "#{key}," unless description.blank?
Severity: Minor
Found in lib/clin/shell_interaction/select.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 too many return statements within this method.
Open

      return nil
Severity: Major
Found in lib/clin/shell_interaction/file_conflict.rb - About 30 mins to fix

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

      def run(statement, default: nil, persist: false)
        default = default.to_sym unless default.nil?
        options = [:yes, :no]
        if persist
          return true if persist?
    Severity: Minor
    Found in lib/clin/shell_interaction/yes_or_no.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 run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def run(statement, choices, default: nil, start_index: 1)
        choices = convert_choices(choices)
        loop do
          shell.say statement
          shell.say choice_help(choices, start_index)
    Severity: Minor
    Found in lib/clin/shell_interaction/select.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 long_argument has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def long_argument
        return nil unless long
        out = long
        if argument
          arg = @optional_argument ? "[#{argument}]" : argument
    Severity: Minor
    Found in lib/clin/option.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