hackedteam/rcs-db

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

Summary

Maintainability
F
5 days
Test Coverage

File config.rb has 527 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rcs-common/trace'

require_relative 'indexer'
require_relative 'migration'

Severity: Major
Found in lib/rcs-db/config.rb - About 1 day to fix

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

      def run(options)
    
        if options[:reset]
          reset_pass options
          return 0
    Severity: Minor
    Found in lib/rcs-db/config.rb - About 7 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 148 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.run!(*argv)
        # reopen the class and declare any empty trace method
        # if called from command line, we don't have the trace facility
        self.class_eval do
          def trace(level, message)
    Severity: Major
    Found in lib/rcs-db/config.rb - About 5 hrs to fix

      Method generate_certificates has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

        def generate_certificates(options)
          trace :info, "Generating ssl certificates..."
      
          # ensure dir is present
          FileUtils.mkdir_p File.join($execution_directory, CERT_DIR)
      Severity: Minor
      Found in lib/rcs-db/config.rb - About 4 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 71 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def run(options)
      
          if options[:reset]
            reset_pass options
            return 0
      Severity: Major
      Found in lib/rcs-db/config.rb - About 2 hrs to fix

        Class Config has 24 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class Config
          include Singleton
          include Tracer
        
          CONF_DIR = 'config'
        Severity: Minor
        Found in lib/rcs-db/config.rb - About 2 hrs to fix

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

            def generate_certificates_anon
              trace :info, "Generating anon ssl certificates..."
          
              # ensure dir is present
              FileUtils.mkdir_p File.join($execution_directory, CERT_DIR)
          Severity: Minor
          Found in lib/rcs-db/config.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 generate_certificates has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def generate_certificates(options)
              trace :info, "Generating ssl certificates..."
          
              # ensure dir is present
              FileUtils.mkdir_p File.join($execution_directory, CERT_DIR)
          Severity: Minor
          Found in lib/rcs-db/config.rb - About 1 hr to fix

            Method generate_certificates_anon has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def generate_certificates_anon
                trace :info, "Generating anon ssl certificates..."
            
                # ensure dir is present
                FileUtils.mkdir_p File.join($execution_directory, CERT_DIR)
            Severity: Minor
            Found in lib/rcs-db/config.rb - About 1 hr to fix

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

                def check_certs
                  unless @global['DB_CERT'].nil?
                    unless File.exist?(Config.instance.cert('DB_CERT'))
                      trace :fatal, "Cannot open certificate file [#{@global['DB_CERT']}]"
                      return false
              Severity: Minor
              Found in lib/rcs-db/config.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

              Avoid too many return statements within this method.
              Open

                    return 0
              Severity: Major
              Found in lib/rcs-db/config.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                      return 0
                Severity: Major
                Found in lib/rcs-db/config.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                        return 0
                  Severity: Major
                  Found in lib/rcs-db/config.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                          return 0
                    Severity: Major
                    Found in lib/rcs-db/config.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                          return 0
                      Severity: Major
                      Found in lib/rcs-db/config.rb - About 30 mins to fix

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

                          def use_pfx_cert(pfx)
                            trace :info, "Using pfx cert for windows code signing..."
                            FileUtils.cp pfx, Config.instance.cert("windows.pfx")
                        
                            trace :info, "Using pfx cert to create Java Applet keystore..."
                        Severity: Minor
                        Found in lib/rcs-db/config.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