berkshelf/ridley

View on GitHub
lib/ridley/chef/cookbook.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Class Cookbook has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Cookbook
    require_relative 'cookbook/metadata'
    require_relative 'cookbook/syntax_check'

    class << self
Severity: Minor
Found in lib/ridley/chef/cookbook.rb - About 2 hrs to fix

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

          def load_root
            [].tap do |files|
              Dir.glob(path.join('*'), File::FNM_DOTMATCH).each do |file|
                next if File.directory?(file)
                next if ignored?(file)
    Severity: Minor
    Found in lib/ridley/chef/cookbook.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 load_recursively has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def load_recursively(category, category_dir, glob)
            [].tap do |files|
              file_spec = path.join(category_dir, '**', glob)
              Dir.glob(file_spec, File::FNM_DOTMATCH).each do |file|
                next if File.directory?(file)
    Severity: Minor
    Found in lib/ridley/chef/cookbook.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 validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate
          raise IOError, "No Cookbook found at: #{path}" unless path.exist?
    
          unless syntax_checker.validate_ruby_files
            raise Ridley::Errors::CookbookSyntaxError, "Invalid ruby files in cookbook: #{cookbook_name} (#{version})."
    Severity: Minor
    Found in lib/ridley/chef/cookbook.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

    There are no issues that match your filters.

    Category
    Status