ripta/drydock

View on GitHub

Showing 240 of 240 total issues

Avoid too many return statements within this method.
Open

      return false if my_vols.keys.size != other_vols.keys.size
Severity: Major
Found in lib/drydock/container_config.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

          return false if my_ports.keys.size != other_ports.keys.size
    Severity: Major
    Found in lib/drydock/container_config.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return false if self['User'] != other['User']
      Severity: Major
      Found in lib/drydock/container_config.rb - About 30 mins to fix

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

            def set(key, value = nil, &blk)
              key = key.to_sym
              fail ArgumentError, "unknown option #{key.inspect}" unless build_opts.key?(key)
              fail ArgumentError, 'one of value or block is required' if value.nil? && blk.nil?
              fail ArgumentError, 'only one of value or block may be provided' if value && blk
        Severity: Minor
        Found in lib/drydock/project.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 log_step has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def log_step(op, *args)
              opts   = args.last.is_a?(Hash) ? args.pop : {}
              optstr = opts.map { |k, v| "#{k}: #{v.inspect}" }.join(', ')
        
              argstr = args.map(&:inspect).join(', ')
        Severity: Minor
        Found in lib/drydock/project.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 author has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def author(name: nil, email: nil)
              if (name.nil? || name.empty?) && (email.nil? || name.empty?)
                fail InvalidInstructionArgumentError, 'at least one of `name:` or `email:` must be provided'
              end
        
        
        Severity: Minor
        Found in lib/drydock/project.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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                    source_chain.run("# EXPORT #{path}", no_commit: true) do |source_container|
                      source_container.archive_get(path + '/.') do |chunk|
                        output.write(chunk.to_s).tap { |b| @total_size += b }
        Severity: Minor
        Found in lib/drydock/instructions/import.rb and 1 other location - About 20 mins to fix
        lib/drydock/instructions/import.rb on lines 31..33

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 28.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                source_chain.run("# EXPORT #{path}", no_commit: true) do |source_container|
                  source_container.archive_get(path + '/.') do |chunk|
                    spool_file.write(chunk.to_s).tap { |b| @total_size += b }
        Severity: Minor
        Found in lib/drydock/instructions/import.rb and 1 other location - About 20 mins to fix
        lib/drydock/instructions/import.rb on lines 50..52

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 28.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            def cmd(command)
              requires_from!(:cmd)
              log_step('cmd', command)
        
              command = ['/bin/sh', '-c', command.to_s] unless command.is_a?(Array)
        Severity: Minor
        Found in lib/drydock/project.rb and 1 other location - About 20 mins to fix
        lib/drydock/project.rb on lines 251..257

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 27.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            def entrypoint(command)
              requires_from!(:entrypoint)
              log_step('entrypoint', command)
        
              command = ['/bin/sh', '-c', command.to_s] unless command.is_a?(Array)
        Severity: Minor
        Found in lib/drydock/project.rb and 1 other location - About 20 mins to fix
        lib/drydock/project.rb on lines 109..115

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 27.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Use 0o for octal literals.
        Open

            def add_entry(name, mode: 0644, mtime: Time.now, _uid: 0, _gid: 0)
        Severity: Minor
        Found in lib/drydock/tar_writer.rb by rubocop

        This cop checks for octal, hex, binary and decimal literals using uppercase prefixes and corrects them to lowercase prefix or no prefix (in case of decimals). eg. for octal use 0o instead of 0 or 0O.

        Can be configured to use 0 only for octal literals using EnforcedOctalStyle => zero_only

        Use alias instead of alias_method in a class body.
        Open

            alias_method :result,  :result_image
        Severity: Minor
        Found in lib/drydock/phase.rb by rubocop

        This cop enforces the use of either #alias or #alias_method depending on configuration. It also flags uses of alias :symbol rather than alias bareword.

        Example: EnforcedStyle: prefer_alias (default)

        # bad
        alias_method :bar, :foo
        alias :bar :foo
        
        # good
        alias bar foo

        Example: EnforcedStyle: preferaliasmethod

        # bad
        alias :bar :foo
        alias bar foo
        
        # good
        alias_method :bar, :foo

        Use alias instead of alias_method in a class body.
        Open

              alias_method :exclude?, :exclude

        This cop enforces the use of either #alias or #alias_method depending on configuration. It also flags uses of alias :symbol rather than alias bareword.

        Example: EnforcedStyle: prefer_alias (default)

        # bad
        alias_method :bar, :foo
        alias :bar :foo
        
        # good
        alias bar foo

        Example: EnforcedStyle: preferaliasmethod

        # bad
        alias :bar :foo
        alias bar foo
        
        # good
        alias_method :bar, :foo

        %i-literals should be delimited by [ and ].
        Open

            IMAGE_EVENTS = %i(delete import pull push tag untag)
        Severity: Minor
        Found in lib/drydock/stream_monitor.rb by rubocop

        This cop enforces the consistent usage of %-literal delimiters.

        Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

        Example:

        # Style/PercentLiteralDelimiters:
        #   PreferredDelimiters:
        #     default: '[]'
        #     '%i':    '()'
        
        # good
        %w[alpha beta] + %i(gamma delta)
        
        # bad
        %W(alpha #{beta})
        
        # bad
        %I(alpha beta)

        Always use raise to signal exceptions.
        Open

                fail NotImplementedError, '#remove must be overridde in the subclass'

        This cop checks for uses of fail and raise.

        Example: EnforcedStyle: only_raise (default)

        # The `only_raise` style enforces the sole use of `raise`.
        # bad
        begin
          fail
        rescue Exception
          # handle it
        end
        
        def watch_out
          fail
        rescue Exception
          # handle it
        end
        
        Kernel.fail
        
        # good
        begin
          raise
        rescue Exception
          # handle it
        end
        
        def watch_out
          raise
        rescue Exception
          # handle it
        end
        
        Kernel.raise

        Example: EnforcedStyle: only_fail

        # The `only_fail` style enforces the sole use of `fail`.
        # bad
        begin
          raise
        rescue Exception
          # handle it
        end
        
        def watch_out
          raise
        rescue Exception
          # handle it
        end
        
        Kernel.raise
        
        # good
        begin
          fail
        rescue Exception
          # handle it
        end
        
        def watch_out
          fail
        rescue Exception
          # handle it
        end
        
        Kernel.fail

        Example: EnforcedStyle: semantic

        # The `semantic` style enforces the use of `fail` to signal an
        # exception, then will use `raise` to trigger an offense after
        # it has been rescued.
        # bad
        begin
          raise
        rescue Exception
          # handle it
        end
        
        def watch_out
          # Error thrown
        rescue Exception
          fail
        end
        
        Kernel.fail
        Kernel.raise
        
        # good
        begin
          fail
        rescue Exception
          # handle it
        end
        
        def watch_out
          fail
        rescue Exception
          raise 'Preferably with descriptive message'
        end
        
        explicit_receiver.fail
        explicit_receiver.raise

        Empty line missing at class body beginning.
        Open

              alias_method :exclude?, :exclude

        This cops checks if empty lines around the bodies of classes match the configuration.

        Example: EnforcedStyle: empty_lines

        # good
        
        class Foo
        
          def bar
            # ...
          end
        
        end

        Example: EnforcedStyle: emptylinesexcept_namespace

        # good
        
        class Foo
          class Bar
        
            # ...
        
          end
        end

        Example: EnforcedStyle: emptylinesspecial

        # good
        class Foo
        
          def bar; end
        
        end

        Example: EnforcedStyle: noemptylines (default)

        # good
        
        class Foo
          def bar
            # ...
          end
        end

        Missing top-level class documentation comment.
        Open

          class InvalidCommandExecutionError < ExecutionError
        Severity: Minor
        Found in lib/drydock/errors.rb by rubocop

        This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

        The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

        Example:

        # bad
        class Person
          # ...
        end
        
        # good
        # Description/Explanation of Person class
        class Person
          # ...
        end

        Extra empty line detected at module body end.
        Open

        
        end
        Severity: Minor
        Found in lib/drydock/drydock.rb by rubocop

        This cops checks if empty lines around the bodies of modules match the configuration.

        Example: EnforcedStyle: empty_lines

        # good
        
        module Foo
        
          def bar
            # ...
          end
        
        end

        Example: EnforcedStyle: emptylinesexcept_namespace

        # good
        
        module Foo
          module Bar
        
            # ...
        
          end
        end

        Example: EnforcedStyle: emptylinesspecial

        # good
        module Foo
        
          def bar; end
        
        end

        Example: EnforcedStyle: noemptylines (default)

        # good
        
        module Foo
          def bar
            # ...
          end
        end

        Always use raise to signal exceptions.
        Open

                    fail InvalidCommandExecutionError,
        Severity: Minor
        Found in lib/drydock/phase_chain.rb by rubocop

        This cop checks for uses of fail and raise.

        Example: EnforcedStyle: only_raise (default)

        # The `only_raise` style enforces the sole use of `raise`.
        # bad
        begin
          fail
        rescue Exception
          # handle it
        end
        
        def watch_out
          fail
        rescue Exception
          # handle it
        end
        
        Kernel.fail
        
        # good
        begin
          raise
        rescue Exception
          # handle it
        end
        
        def watch_out
          raise
        rescue Exception
          # handle it
        end
        
        Kernel.raise

        Example: EnforcedStyle: only_fail

        # The `only_fail` style enforces the sole use of `fail`.
        # bad
        begin
          raise
        rescue Exception
          # handle it
        end
        
        def watch_out
          raise
        rescue Exception
          # handle it
        end
        
        Kernel.raise
        
        # good
        begin
          fail
        rescue Exception
          # handle it
        end
        
        def watch_out
          fail
        rescue Exception
          # handle it
        end
        
        Kernel.fail

        Example: EnforcedStyle: semantic

        # The `semantic` style enforces the use of `fail` to signal an
        # exception, then will use `raise` to trigger an offense after
        # it has been rescued.
        # bad
        begin
          raise
        rescue Exception
          # handle it
        end
        
        def watch_out
          # Error thrown
        rescue Exception
          fail
        end
        
        Kernel.fail
        Kernel.raise
        
        # good
        begin
          fail
        rescue Exception
          # handle it
        end
        
        def watch_out
          fail
        rescue Exception
          raise 'Preferably with descriptive message'
        end
        
        explicit_receiver.fail
        explicit_receiver.raise

        Use alias instead of alias_method in a class body.
        Open

            alias_method :result=, :result_image=
        Severity: Minor
        Found in lib/drydock/phase.rb by rubocop

        This cop enforces the use of either #alias or #alias_method depending on configuration. It also flags uses of alias :symbol rather than alias bareword.

        Example: EnforcedStyle: prefer_alias (default)

        # bad
        alias_method :bar, :foo
        alias :bar :foo
        
        # good
        alias bar foo

        Example: EnforcedStyle: preferaliasmethod

        # bad
        alias :bar :foo
        alias bar foo
        
        # good
        alias_method :bar, :foo
        Severity
        Category
        Status
        Source
        Language