khozlov/kitchen-scribe

View on GitHub

Showing 6 of 6 total issues

File scribe_adjust.rb has 282 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'chef/mixin/deep_merge'
require 'chef/mixin/shell_out'

class Chef
  class Knife
Severity: Minor
Found in lib/chef/knife/scribe_adjust.rb - About 2 hrs to fix

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

          def parse_adjustment_file(filename)
            if !File.exists?(filename)
              errors.last["general"] = "File does not exist!"
            else
              begin
    Severity: Minor
    Found in lib/chef/knife/scribe_adjust.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_adjustments has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def parse_adjustments
            @name_args.each do |filename|
              errors.push({ "name" => filename, "general" => nil, "adjustments" => {} })
              parse_adjustment_file(filename)
            end
    Severity: Minor
    Found in lib/chef/knife/scribe_adjust.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 deep_delete! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def deep_delete!(delete_from, delete_spec)
          if delete_from.kind_of?(Hash) || delete_from.kind_of?(Array)
            if delete_spec.kind_of?(Array)
              delete_spec.each { |item| deep_delete!(delete_from, item) }
            elsif delete_spec.kind_of?(Hash)
    Severity: Minor
    Found in lib/chef/knife/scribe_adjust.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 adjustment_valid? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def adjustment_valid?(adjustment, index)
            unless adjustment.kind_of?(Hash)
              errors.last["adjustments"].store(index,"Adjustment must be a JSON hash!")
              return false
            end
    Severity: Minor
    Found in lib/chef/knife/scribe_adjust.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 run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def run
            configure
            Dir.mkdir(config[:chronicle_path]) unless File.directory?(config[:chronicle_path])
            init_chronicle
            setup_remote if config[:remote_url]
    Severity: Minor
    Found in lib/chef/knife/scribe_hire.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