schmich/tome

View on GitHub

Showing 16 of 16 total issues

File command.rb has 354 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'io/console'
require 'passgen'
require 'clipboard'

module Tome
Severity: Minor
Found in lib/tome/command.rb - About 4 hrs to fix

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

      class Tome
        def self.exists?(tome_filename)
          return !load_tome(tome_filename).nil?
        end
    
    
    Severity: Minor
    Found in lib/tome/tome.rb - About 2 hrs to fix

      Class Command has 22 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Command
          private_class_method :new 
      
          def self.run(tome_filename, args, stdout = $stdout, stderr = $stderr, stdin = $stdin)
            command = new()
      Severity: Minor
      Found in lib/tome/command.rb - About 2 hrs to fix

        Consider simplifying this complex logical expression.
        Open

              raise ArgumentError if
                opts.nil? || opts.empty? || opts[:value].nil? ||
                opts[:password].nil? || opts[:password].empty? ||
                opts[:salt].nil? || opts[:salt].empty? ||
                opts[:iv].nil? || opts[:iv].empty? ||
        Severity: Critical
        Found in lib/tome/crypt.rb - About 2 hrs to fix

          File tome.rb has 251 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'yaml'
          require 'fileutils'
          
          module Tome
            class MasterPasswordError < RuntimeError
          Severity: Minor
          Found in lib/tome/tome.rb - About 2 hrs to fix

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

                def help(args)
                  if args.length > 1
                    raise CommandError, "Invalid arguments.\n\n#{$usage}"
                  end
            
            
            Severity: Minor
            Found in lib/tome/command.rb - About 1 hr to fix

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

                  def set(args)
                    if args.length < 1 || args.length > 2
                      raise CommandError, "Invalid arguments.\n\n#{$set_usage}"
                    end
                    
              Severity: Minor
              Found in lib/tome/command.rb - About 1 hr to fix

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

                    def set(args)
                      if args.length < 1 || args.length > 2
                        raise CommandError, "Invalid arguments.\n\n#{$set_usage}"
                      end
                      
                Severity: Minor
                Found in lib/tome/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

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

                    def self.validate_tome(tome)
                      if tome[:version].nil? || tome[:version].class != Fixnum
                        raise FileFormatError, 'The tome database is invalid (missing or invalid version).'
                      end
                
                
                Severity: Minor
                Found in lib/tome/tome.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 run has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def self.run(tome_filename, args, stdout = $stdout, stderr = $stderr, stdin = $stdin)
                Severity: Minor
                Found in lib/tome/command.rb - About 35 mins to fix

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

                      def run(tome_filename, args, stdout, stderr, stdin)
                  Severity: Minor
                  Found in lib/tome/command.rb - About 35 mins to fix

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

                        def copy(args)
                          if args.length != 1
                            raise CommandError, "Invalid arguments.\n\n#{$copy_usage}"
                          end
                    
                    
                    Severity: Minor
                    Found in lib/tome/command.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 tome_connect has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def tome_connect
                          if !Tome.exists?(@tome_filename)
                            raise CommandError, "Tome database does not exist. Use 'tome set' or 'tome generate' to create a password first."
                          end
                    
                    
                    Severity: Minor
                    Found in lib/tome/command.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 delete has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def delete(args)
                          if args.length != 1
                            raise CommandError, "Invalid arguments.\n\n#{$delete_usage}"
                          end
                    
                    
                    Severity: Minor
                    Found in lib/tome/command.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 generate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def generate(args)
                          if args.length != 1
                            raise CommandError, "Invalid arguments.\n\n#{$generate_usage}"
                          end
                          
                    Severity: Minor
                    Found in lib/tome/command.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 rename has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def rename(args)
                          if args.count != 2
                            raise CommandError, "Invalid arguments.\n\n#{$rename_usage}"
                          end
                    
                    
                    Severity: Minor
                    Found in lib/tome/command.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

                    Severity
                    Category
                    Status
                    Source
                    Language