ayemos/lamma

View on GitHub

Showing 19 of 19 total issues

Cyclomatic complexity for initialize is too high. [7/6]
Open

    def initialize(str)
      @type =
        case str
        when /^c[s#](harp)?$/i
          ::Lamma::Runtime::C_SHARP
Severity: Minor
Found in lib/lamma/runtime.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Cyclomatic complexity for run is too high. [7/6]
Open

    def run
      unless File.exist?(@conf_path)
        abort("Config file #{@conf_path} is missing.")
      end

Severity: Minor
Found in lib/lamma/cli/rollback.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Method prebuild has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def prebuild
      if @prebuild
        Lamma.logger.info 'Running prebuild script...'
        raise unless system(@prebuild)
      elsif [Lamma::Runtime::PYTHON_27, Lamma::Runtime::PYTHON_36].include?(@function.runtime.type) \
Severity: Minor
Found in lib/lamma/code.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 has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def run
      if Dir.exist?(target)
        Lamma.logger.fatal "Directory '#{target}' already exists."
        exit(1)
      end
Severity: Minor
Found in lib/lamma/cli/init.rb - About 1 hr to fix

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

        def run
          unless File.exist?(@conf_path)
            abort("Config file #{@conf_path} is missing.")
          end
    
    
    Severity: Minor
    Found in lib/lamma/cli/rollback.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 create_initial_role has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def create_initial_role(role_name)
          begin
            Lamma.logger.info("Creating role #{role_name}")
            resp = iam.create_role({
              assume_role_policy_document: DEFAULT_LAMBDA_ASSUME_ROLE_POLICY.to_json,
    Severity: Minor
    Found in lib/lamma/cli/init.rb - About 1 hr to fix

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

          def run
            if Dir.exist?(target)
              Lamma.logger.fatal "Directory '#{target}' already exists."
              exit(1)
            end
      Severity: Minor
      Found in lib/lamma/cli/init.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 has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def run
            unless File.exist?(@conf_path)
              abort("Config file #{@conf_path} is missing.")
            end
      
      
      Severity: Minor
      Found in lib/lamma/cli/rollback.rb - About 1 hr to fix

        Method zip_and_save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def zip_and_save
              io = Zip::OutputStream.write_buffer do |zio|
                active_paths.each do |path|
                  next unless File.file?(path)
                  File.open(path) do |source_io|
        Severity: Minor
        Found in lib/lamma/code.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

        Method update_or_create_alias has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_or_create_alias(f, new_version)
              a = Lamma::Alias.new(f, options['alias'], new_version)
        
              if a.remote_exist? && a.remote_version
                last_version = a.remote_version
        Severity: Minor
        Found in lib/lamma/cli/deploy.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

        Method create_initial_role has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def create_initial_role(role_name)
              begin
                Lamma.logger.info("Creating role #{role_name}")
                resp = iam.create_role({
                  assume_role_policy_document: DEFAULT_LAMBDA_ASSUME_ROLE_POLICY.to_json,
        Severity: Minor
        Found in lib/lamma/cli/init.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

        unexpected token tCOLON (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
        Open

                    'Effect': 'Allow',
        Severity: Minor
        Found in lib/lamma/cli/init.rb by rubocop

        unexpected token tCOLON (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
        Open

                'Version': '2012-10-17',
        Severity: Minor
        Found in lib/lamma/cli/init.rb by rubocop

        Method Lamma::Alias#description is defined at both lib/lamma/alias.rb:3 and lib/lamma/alias.rb:66.
        Open

            def description
        Severity: Minor
        Found in lib/lamma/alias.rb by rubocop

        This cop checks for duplicated instance (or singleton) method definitions.

        Example:

        # bad
        
        def duplicated
          1
        end
        
        def duplicated
          2
        end

        Example:

        # bad
        
        def duplicated
          1
        end
        
        alias duplicated other_duplicated

        Example:

        # good
        
        def duplicated
          1
        end
        
        def other_duplicated
          2
        end

        Unused method argument - function_name. If it's necessary, use _ or _function_name as an argument name to indicate that it won't be used. You can also write as show(*) if you want the method to accept any arguments but don't care about them.
        Open

            def show(function_name)
        Severity: Minor
        Found in lib/lamma/cli.rb by rubocop

        This cop checks for unused method arguments.

        Example:

        # bad
        
        def some_method(used, unused, _unused_but_allowed)
          puts used
        end

        Example:

        # good
        
        def some_method(used, _unused, _unused_but_allowed)
          puts used
        end

        unexpected token error (Using Ruby 2.1 parser; configure using TargetRubyVersion parameter, under AllCops)
        Open

              raise Exception("Invalid source_path #{@source_path}") if @source_path&.empty?
        Severity: Minor
        Found in lib/lamma/code.rb by rubocop

        XXX found
        Open

              thor.say(f) # XXX:
        Severity: Minor
        Found in lib/lamma/cli/show.rb by fixme

        XXX found
        Open

              if true # XXX: option save_builds?
        Severity: Minor
        Found in lib/lamma/code.rb by fixme

        TODO found
        Open

              # TODO: impl
        Severity: Minor
        Found in lib/lamma/code.rb by fixme
        Severity
        Category
        Status
        Source
        Language