fnichol/knife-server

View on GitHub

Showing 2 of 15 total issues

Method included has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.included(included_class) # rubocop:disable Metrics/MethodLength
        included_class.class_eval do

          deps do
            require "chef/knife/ssh"
Severity: Major
Found in lib/chef/knife/server_bootstrap_base.rb - About 2 hrs to fix

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

          def backup_component(component)
            c = COMPONENTS[component]
            dir_path = ::File.join(backup_dir, component)
            ui.msg "Creating #{c[:singular]} backups in #{dir_path}"
            FileUtils.mkdir_p(dir_path)
    Severity: Minor
    Found in lib/chef/knife/server_backup.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