RiotGames/berkshelf

View on GitHub

Showing 54 of 54 total issues

Method try_download has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

    def try_download(source, name, version)
      unless ( remote_cookbook = source.cookbook(name, version) )
        return nil
      end

Severity: Minor
Found in lib/berkshelf/downloader.rb - About 1 day 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

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

    File errors.rb has 420 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Berkshelf
      class BerkshelfError < StandardError
        class << self
          # @param [Integer] code
          def set_status_code(code)
    Severity: Minor
    Found in lib/berkshelf/errors.rb - About 6 hrs to fix

      File cli.rb has 384 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require_relative "../berkshelf"
      require_relative "config"
      require_relative "commands/shelf"
      
      module Berkshelf
      Severity: Minor
      Found in lib/berkshelf/cli.rb - About 5 hrs to fix

        Method try_download has 112 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def try_download(source, name, version)
              unless ( remote_cookbook = source.cookbook(name, version) )
                return nil
              end
        
        
        Severity: Major
        Found in lib/berkshelf/downloader.rb - About 4 hrs to fix

          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

            Method upload has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

                def upload(cookbooks)
                  Berkshelf.log.info "Starting upload"
            
                  Berkshelf.ridley_connection(options) do |connection|
                    # this is a hack to work around a bug in chef 13.0-13.2 protocol negotiation on POST requests, its only
            Severity: Minor
            Found in lib/berkshelf/uploader.rb - About 3 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

            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

              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 pretty_print has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                    def pretty_print
                      [].tap do |a|
                        a.push "        Name: #{cookbook_name}" if name && name =~ /\S/
                        a.push "     Version: #{version}" if version && version =~ /\S/
                        a.push " Description: #{metadata.description}" if metadata.description && metadata.description =~ /\S/
                Severity: Minor
                Found in lib/berkshelf/cached_cookbook.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 pretty_hash has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    def pretty_hash
                      {}.tap do |h|
                        h[:name]          = cookbook_name if cookbook_name && cookbook_name =~ /\S/
                        h[:version]       = version if version && version =~ /\S/
                        h[:description]   = description if description && description =~ /\S/
                Severity: Minor
                Found in lib/berkshelf/cached_cookbook.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 ridley_connection has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def ridley_connection(options = {}, &block)
                          ssl_options              = {}
                          ssl_options[:verify]     = if options[:ssl_verify].nil?
                                                       Berkshelf.config.ssl.verify
                                                     else
                    Severity: Minor
                    Found in lib/berkshelf.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 initialize has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def initialize(path = self.class.path)
                          # this is a bit tricky, mixlib-config wants to extend a class and create effectively a global config object while
                          # what we want to do is use an instance, so we create an anonymous class and shove it into an instance variable.
                          # this is actually similar to what mixlib-config itself does to create config contexts.
                          @klass = Class.new
                    Severity: Minor
                    Found in lib/berkshelf/config.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 extended has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def self.extended(base)
                            base.class_exec do
                              config_strict_mode true
                              config_context :api do
                                default :timeout, "30"
                    Severity: Minor
                    Found in lib/berkshelf/config.rb - About 1 hr to fix

                      Method sync has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def sync(source, destination, options = {})
                            unless File.directory?(source)
                              raise ArgumentError, "`source' must be a directory, but was a " \
                                "`#{File.ftype(source)}'! If you just want to sync a file, use " \
                                "the `copy' method instead."
                      Severity: Minor
                      Found in lib/berkshelf/file_syncer.rb - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language