hackedteam/rcs-db

View on GitHub
lib/rcs-db/backup.rb

Summary

Maintainability
D
1 day
Test Coverage

Method do_backup has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  def self.do_backup(now, backup, save_status = true)

    trace :info, "Performing backup [#{backup.name}]..."

    Audit.log :actor => '<system>', :action => 'backup.start', :desc => "Performing backup #{backup.name}"
Severity: Minor
Found in lib/rcs-db/backup.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

Method perform has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def self.perform

    now = Time.now.getutc

    begin
Severity: Minor
Found in lib/rcs-db/backup.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 do_backup has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.do_backup(now, backup, save_status = true)

    trace :info, "Performing backup [#{backup.name}]..."

    Audit.log :actor => '<system>', :action => 'backup.start', :desc => "Performing backup #{backup.name}"
Severity: Major
Found in lib/rcs-db/backup.rb - About 2 hrs to fix

    File backup.rb has 252 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require_relative 'db_layer'
    
    # from RCS::Common
    require 'rcs-common/trace'
    
    
    Severity: Minor
    Found in lib/rcs-db/backup.rb - About 2 hrs to fix

      Method filter_for_partial_backup has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.filter_for_partial_backup(params)
      
          # extract the id from the string
          id = Moped::BSON::ObjectId.from_string(params[:what][-24..-1])
      
      
      Severity: Minor
      Found in lib/rcs-db/backup.rb - About 1 hr to fix

        Method backup_index has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.backup_index
            index = []
        
            glob = File.join File.expand_path(Config.instance.global['BACKUP_DIR']), '*'
        
        
        Severity: Minor
        Found in lib/rcs-db/backup.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 restore_backup has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.restore_backup(params)
            trace :info, "Restoring backup: #{params['_id']}"
        
            backup_path = File.join File.expand_path(Config.instance.global['BACKUP_DIR']), params['_id']
        
        
        Severity: Minor
        Found in lib/rcs-db/backup.rb - About 1 hr to fix

          Method get_last_incremental_id has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.get_last_incremental_id(params)
              session = DB.instance.session
          
              incremental_ids = {}
          
          
          Severity: Minor
          Found in lib/rcs-db/backup.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 filter_for_partial_backup has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.filter_for_partial_backup(params)
          
              # extract the id from the string
              id = Moped::BSON::ObjectId.from_string(params[:what][-24..-1])
          
          
          Severity: Minor
          Found in lib/rcs-db/backup.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

          There are no issues that match your filters.

          Category
          Status