RiotGames/berkshelf

View on GitHub
lib/berkshelf/lockfile.rb

Summary

Maintainability
F
3 days
Test Coverage

File lockfile.rb has 449 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require_relative "dependency"
require "chef/environment"

module Berkshelf
  class Lockfile
Severity: Minor
Found in lib/berkshelf/lockfile.rb - About 6 hrs to fix

    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
    Severity: Minor
    Found in lib/berkshelf/lockfile.rb - About 2 hrs to fix

      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 = {}
      
      
      Severity: Minor
      Found in lib/berkshelf/lockfile.rb - About 2 hrs 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 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 ""
      Severity: Minor
      Found in lib/berkshelf/lockfile.rb - About 2 hrs 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 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 ""
      Severity: Major
      Found in lib/berkshelf/lockfile.rb - About 2 hrs to fix

        Method run has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

              def run
                @parsed_dependencies = {}
        
                contents = File.read(@lockfile.filepath)
        
        
        Severity: Minor
        Found in lib/berkshelf/lockfile.rb - About 2 hrs 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 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def run
                @parsed_dependencies = {}
        
                contents = File.read(@lockfile.filepath)
        
        
        Severity: Major
        Found in lib/berkshelf/lockfile.rb - About 2 hrs to fix

          Method trusted? has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def trusted?
                Berkshelf.log.info "Checking if lockfile is trusted"
          
                checked = {}
          
          
          Severity: Minor
          Found in lib/berkshelf/lockfile.rb - About 1 hr to fix

            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
            Severity: Minor
            Found in lib/berkshelf/lockfile.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 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}"
            
            
            Severity: Minor
            Found in lib/berkshelf/lockfile.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

            Avoid too many return statements within this method.
            Open

                      return false
            Severity: Major
            Found in lib/berkshelf/lockfile.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                        return false
              Severity: Major
              Found in lib/berkshelf/lockfile.rb - About 30 mins to fix

                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)
                Severity: Minor
                Found in lib/berkshelf/lockfile.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