RiotGames/berkshelf

View on GitHub
lib/berkshelf/berksfile.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Berksfile has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Berksfile
    class << self
      # Instantiate a Berksfile from the given options. This method is used
      # heavily by the CLI to reduce duplication.
      #
Severity: Minor
Found in lib/berkshelf/berksfile.rb - About 4 hrs to fix

    File berksfile.rb has 298 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require_relative "packager"
    
    require "chef/cookbook/chefignore"
    require "chef/util/path_helper"
    
    
    Severity: Minor
    Found in lib/berkshelf/berksfile.rb - About 3 hrs to fix

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

          def add_dependency(name, constraint = nil, options = {})
            if @dependencies[name]
              # Only raise an exception if the dependency is a true duplicate
              groups = (options[:group].nil? || options[:group].empty?) ? [:default] : options[:group]
              unless (@dependencies[name].groups & groups).empty?
      Severity: Minor
      Found in lib/berkshelf/berksfile.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 outdated has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def outdated(*names, include_non_satisfying: false)
            validate_lockfile_present!
            validate_lockfile_trusted!
            validate_dependencies_installed!
            validate_cookbook_names!(names)
      Severity: Minor
      Found in lib/berkshelf/berksfile.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 find_chefignore has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def find_chefignore(path)
            filename = "chefignore"
      
            Pathname.new(path).ascend do |dir|
              next unless dir.directory?
      Severity: Minor
      Found in lib/berkshelf/berksfile.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

      There are no issues that match your filters.

      Category
      Status