backupii/backupii

View on GitHub

Showing 78 of 78 total issues

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

      def new_email
        method = %w[smtp sendmail exim file test]
          .index(@delivery_method.to_s) ? @delivery_method.to_s : "smtp"

        options =
Severity: Minor
Found in lib/backup/notifier/mail.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 perform! has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def perform!
      Logger.info "Creating Archive '#{name}'..."

      path = File.join(Config.tmp_path, @model.trigger, "archives")
      FileUtils.mkdir_p(path)
Severity: Minor
Found in lib/backup/archive.rb - About 1 hr to fix

    Method run has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def run(command)
            name = command_name(command)
            Logger.info "Running system utility '#{name}'..."
    
            begin
    Severity: Minor
    Found in lib/backup/utilities.rb - About 1 hr to fix

      Method notify! has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def notify!(status)
              incident_description = "Backup - #{model.label}"
              incident_key = "backup/#{model.trigger}"
              incident_details = {
                incident_key: incident_key,
      Severity: Minor
      Found in lib/backup/notifier/pagerduty.rb - About 1 hr to fix

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

            def run
              Open4.popen4(pipeline) do |_pid, _stdin, stdout, stderr|
                pipestatus = stdout.read.delete("\n").split(":").sort
                pipestatus.each do |status|
                  index, exitstatus = status.split("|").map(&:to_i)
        Severity: Minor
        Found in lib/backup/pipeline.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 check_configuration has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def check_configuration
                required =
                  if use_iam_profile
                    %w[bucket]
                  else
        Severity: Minor
        Found in lib/backup/storage/s3.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 process_orphans has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

                def process_orphans
                  if @orphans.empty?
                    return mirror ? "Deleted Files: 0" : "Orphaned Files: 0"
                  end
        
        
        Severity: Minor
        Found in lib/backup/syncer/cloud/base.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 sync_file has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

                def sync_file(local_file, remote_path, remote_md5)
                  if local_file && File.exist?(local_file.path)
                    if local_file.md5 == remote_md5
                      MUTEX.synchronize { @unchanged_count += 1 }
                    else
        Severity: Minor
        Found in lib/backup/syncer/cloud/base.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 initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize(obj = nil, wrapped_exception = nil)
              @wrapped_exception = wrapped_exception
              msg = (obj.respond_to?(:to_str) ? obj.to_str : obj.to_s)
                .gsub(%r{^ *}, "  ").strip
              msg = clean_name(self.class.name) + (msg.empty? ? "" : ": #{msg}")
        Severity: Minor
        Found in lib/backup/errors.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 command_name has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

              def command_name(command)
                parts = []
                command = command.split(" ")
                command.shift while command[0].to_s.include?("=")
                parts << command.shift.split("/")[-1]
        Severity: Minor
        Found in lib/backup/utilities.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 warnings has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def warnings(model)
                messages = []
        
                packaging_folder = File.join(Config.tmp_path, model.trigger)
                if File.exist?(packaging_folder)
        Severity: Minor
        Found in lib/backup/cleaner.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 prepare has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def prepare(model)
                messages = []
        
                packaging_folder = File.join(Config.tmp_path, model.trigger)
                if File.exist?(packaging_folder)
        Severity: Minor
        Found in lib/backup/cleaner.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 set_path_variable has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def set_path_variable(name, path, ending, root_path)
                # strip any trailing '/' in case the user supplied this as part of
                # an absolute path, so we can match it against File.expand_path()
                path = path.to_s.sub(%r{/\s*$}, "").lstrip
                new_path = false
        Severity: Minor
        Found in lib/backup/config.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 truncate! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def truncate!
                return unless File.exist?(@logfile)
        
                if File.stat(@logfile).size > @options.max_bytes
                  FileUtils.cp(@logfile, @logfile + "~")
        Severity: Minor
        Found in lib/backup/logger/logfile.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 backup_perform has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def backup_perform(triggers, *options)
              triggers = Array(triggers).map(&:to_s)
              opts = options.last.is_a?(Hash) ? options.pop : {}
              exit_status = opts.delete(:exit_status)
              argv = ["perform", "-t", triggers.join(",")] + options
        Severity: Minor
        Found in integration/support/example_helpers.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 format_arg has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def format_arg(arg, status)
                if arg.respond_to?(:call)
                  arg.call(model, status)
                else
                  arg.gsub(%r{%(\w)}) do |match|
        Severity: Minor
        Found in lib/backup/notifier/command.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

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

              def transfer!
                connection do |ftp|
                  create_remote_path(ftp)
        
                  package.filenames.each do |filename|
        Severity: Minor
        Found in lib/backup/storage/ftp.rb and 1 other location - About 40 mins to fix
        lib/backup/storage/sftp.rb on lines 35..43

        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 38.

        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 transfer!
                connection do |sftp|
                  create_remote_path(sftp)
        
                  package.filenames.each do |filename|
        Severity: Minor
        Found in lib/backup/storage/sftp.rb and 1 other location - About 40 mins to fix
        lib/backup/storage/ftp.rb on lines 71..79

        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 38.

        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

        Method upload_parts has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def upload_parts(src, dest, upload_id, chunk_bytes, file_size)
        Severity: Minor
        Found in lib/backup/cloud_io/s3.rb - About 35 mins to fix

          Method setup_gpg_homedir has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def setup_gpg_homedir
                  return false unless gpg_homedir
          
                  path = File.expand_path(gpg_homedir)
                  FileUtils.mkdir_p(path)
          Severity: Minor
          Found in lib/backup/encryptor/gpg.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
          Source
          Language