File lockfile.rb
has 449 lines of code (exceeds 250 allowed). Consider refactoring. Open
require_relative "dependency"
require "chef/environment"
module Berkshelf
class Lockfile
Class Lockfile
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class Lockfile
class << self
# Initialize a Lockfile from the given filepath
#
# @param [String] filepath
Method trusted?
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def trusted?
Berkshelf.log.info "Checking if lockfile is trusted"
checked = {}
- Read upRead up
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 reduce!
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def reduce!
Berkshelf.log.info "Reducing lockfile"
Berkshelf.log.debug "Current lockfile:"
Berkshelf.log.debug ""
- Read upRead up
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 reduce!
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
def reduce!
Berkshelf.log.info "Reducing lockfile"
Berkshelf.log.debug "Current lockfile:"
Berkshelf.log.debug ""
Method run
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def run
@parsed_dependencies = {}
contents = File.read(@lockfile.filepath)
- Read upRead up
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 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run
@parsed_dependencies = {}
contents = File.read(@lockfile.filepath)
Method trusted?
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def trusted?
Berkshelf.log.info "Checking if lockfile is trusted"
checked = {}
Method apply
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def apply(name, options = {})
locks = graph.locks.inject({}) do |hash, (dep_name, dependency)|
hash[dep_name] = "= #{dependency.locked_version}"
hash
end
- Read upRead up
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 satisfies_transitive?
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def satisfies_transitive?(graph_item, checked, level = 0)
indent = " " * (level + 2)
Berkshelf.log.debug "#{indent}Checking transitive dependencies for #{graph_item}"
- Read upRead up
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 false
Avoid too many return
statements within this method. Open
return false
Method locks
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def locks
@graph.sort.inject({}) do |hash, (name, item)|
dependency = @lockfile.find(name) ||
@berksfile && @berksfile.find(name) ||
Dependency.new(@berksfile, name)
- Read upRead up
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"