ryotarai/itamae

View on GitHub

File base.rb has 295 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'itamae'
require 'shellwords'
require 'hashie'

module Itamae
Severity: Minor
Found in lib/itamae/resource/base.rb - About 3 hrs to fix

    Class Base has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Base
          class EvalContext
            attr_reader :attributes
            attr_reader :notifications
            attr_reader :subscriptions
    Severity: Minor
    Found in lib/itamae/resource/base.rb - About 3 hrs to fix

      Method run_action has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

            def run_action(action)
              runner.handler.event(:action, action: action) do
                original_attributes = @attributes # preserve and restore later
                @current_action = action
      
      
      Severity: Minor
      Found in lib/itamae/resource/base.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 a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def run(specific_action = nil)
              runner.handler.event(:resource, resource_type: resource_type, resource_name: resource_name) do
                Itamae.logger.debug "#{resource_type}[#{resource_name}]"
      
                Itamae.logger.with_indent_if(Itamae.logger.debug?) do
      Severity: Minor
      Found in lib/itamae/resource/base.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 process_attributes has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

            def process_attributes
              self.class.defined_attributes.each_pair do |key, details|
                @attributes[key] ||= @resource_name if details[:default_name]
                @attributes[key] = details[:default] if details.has_key?(:default) && !@attributes.has_key?(key)
      
      
      Severity: Minor
      Found in lib/itamae/resource/base.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 action_create has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

            def action_create(options)
              if run_specinfra(:check_user_exists, attributes.username)
                if attributes.uid && attributes.uid != current.uid
                  run_specinfra(:update_user_uid, attributes.username, attributes.uid)
                  updated!
      Severity: Minor
      Found in lib/itamae/resource/user.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 action_create has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def action_create(options)
              if !current.exist && !@temppath
                run_command(["touch", attributes.path])
              end
      
      
      Severity: Minor
      Found in lib/itamae/resource/file.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 action_create has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def action_create(options)
              if run_specinfra(:check_user_exists, attributes.username)
                if attributes.uid && attributes.uid != current.uid
                  run_specinfra(:update_user_uid, attributes.username, attributes.uid)
                  updated!
      Severity: Minor
      Found in lib/itamae/resource/user.rb - About 1 hr to fix

        Method run_action has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def run_action(action)
                runner.handler.event(:action, action: action) do
                  original_attributes = @attributes # preserve and restore later
                  @current_action = action
        
        
        Severity: Minor
        Found in lib/itamae/resource/base.rb - About 1 hr to fix

          Method action_sync has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                def action_sync(options)
                  ensure_git_available
          
                  new_repository = false
          
          
          Severity: Minor
          Found in lib/itamae/resource/git.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 run_command has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def run_command(commands, options = {})
                  options = {error: true}.merge(options)
          
                  command = build_command(commands, options)
                  Itamae.logger.debug "Executing `#{command}`..."
          Severity: Minor
          Found in lib/itamae/backend.rb - About 1 hr to fix

            Method action_sync has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def action_sync(options)
                    ensure_git_available
            
                    new_repository = false
            
            
            Severity: Minor
            Found in lib/itamae/resource/git.rb - About 1 hr to fix

              Method run_command has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                    def run_command(commands, options = {})
                      options = {error: true}.merge(options)
              
                      command = build_command(commands, options)
                      Itamae.logger.debug "Executing `#{command}`..."
              Severity: Minor
              Found in lib/itamae/backend.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 find_recipe_in_gem has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def find_recipe_in_gem(recipe)
                      plugin_name, recipe_file = recipe.split('::', 2)
                      recipe_file = recipe_file.gsub("::", "/") if recipe_file
              
                      gem_name = "itamae-plugin-recipe-#{plugin_name}"
              Severity: Minor
              Found in lib/itamae/recipe.rb - About 55 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 compare_file has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def compare_file
                      compare_to = if current.exist
                                     attributes.path
                                   else
                                     '/dev/null'
              Severity: Minor
              Found in lib/itamae/resource/file.rb - About 55 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_source_file has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def find_source_file
                      if attributes.source == :auto
                        dirs = attributes.path.split(::File::SEPARATOR)
                        dirs.shift if dirs.first == ""
              
              
              Severity: Minor
              Found in lib/itamae/resource/remote_file.rb - About 55 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 notify has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                    def notify
                      (notifications + recipe.children.subscribing(self)).each do |notification|
                        message = "Notifying #{notification.action} to #{notification.action_resource.resource_type} resource '#{notification.action_resource.resource_name}'"
              
                        if notification.delayed?
              Severity: Minor
              Found in lib/itamae/resource/base.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 action_create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                    def action_create(options)
                      if attributes.mode
                        run_specinfra(:change_file_mode, @temppath, attributes.mode)
                      end
                      if attributes.owner || attributes.group
              Severity: Minor
              Found in lib/itamae/resource/remote_directory.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 show_differences has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def show_differences
                      @current_attributes.each_pair do |key, current_value|
                        value = @attributes[key]
                        if current_value.nil? && value.nil?
                          # ignore
              Severity: Minor
              Found in lib/itamae/resource/base.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 action_edit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def action_edit(options)
                      if attributes.mode
                        run_specinfra(:change_file_mode, @temppath, attributes.mode)
                      else
                        run_command(['chmod', '--reference', attributes.path, @temppath])
              Severity: Minor
              Found in lib/itamae/resource/file.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

              Severity
              Category
              Status