hammackj/risu

View on GitHub
lib/risu/cli/application.rb

Summary

Maintainability
D
3 days
Test Coverage

File application.rb has 361 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Risu
    module CLI

        # Application class for Risu
        class Application
Severity: Minor
Found in lib/risu/cli/application.rb - About 4 hrs to fix

    Method parse_options has 92 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                def parse_options
                    begin
                        opts = OptionParser.new do |opt|
                            opt.banner =    "#{APP_NAME} v#{VERSION}\nJacob Hammack\nhttp://www.hammackj.com\n\n"
                            opt.banner << "Usage: #{APP_NAME} [options] [files_to_parse]"
    Severity: Major
    Found in lib/risu/cli/application.rb - About 3 hrs to fix

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

                  def run
                      parse_options
      
                      if @options[:list_templates]
                          @template_manager.display_templates
      Severity: Major
      Found in lib/risu/cli/application.rb - About 2 hrs to fix

        Method parse_options has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

                    def parse_options
                        begin
                            opts = OptionParser.new do |opt|
                                opt.banner =    "#{APP_NAME} v#{VERSION}\nJacob Hammack\nhttp://www.hammackj.com\n\n"
                                opt.banner << "Usage: #{APP_NAME} [options] [files_to_parse]"
        Severity: Minor
        Found in lib/risu/cli/application.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 run has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

                    def run
                        parse_options
        
                        if @options[:list_templates]
                            @template_manager.display_templates
        Severity: Minor
        Found in lib/risu/cli/application.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 migrate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

                    def migrate direction
                        begin
                            if @database["adapter"] == nil
                                return false, "[!] Invalid database adapter, please check your configuration file"
                            end
        Severity: Minor
        Found in lib/risu/cli/application.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 load_config has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

                    def load_config file=CONFIG_FILE, in_memory_config=false
                        if File.exist?(file) == true or in_memory_config == true
                            begin
                                if in_memory_config
                                    yaml = YAML::load(file)
        Severity: Minor
        Found in lib/risu/cli/application.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 db_connect has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

                    def db_connect
                        begin
                            if @database["adapter"] == nil
                                puts "[!] #{@database['adapter']}" if @options[:debug]
        
        
        Severity: Minor
        Found in lib/risu/cli/application.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 db_connect has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    def db_connect
                        begin
                            if @database["adapter"] == nil
                                puts "[!] #{@database['adapter']}" if @options[:debug]
        
        
        Severity: Minor
        Found in lib/risu/cli/application.rb - About 1 hr to fix

          Method migrate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                      def migrate direction
                          begin
                              if @database["adapter"] == nil
                                  return false, "[!] Invalid database adapter, please check your configuration file"
                              end
          Severity: Minor
          Found in lib/risu/cli/application.rb - About 1 hr to fix

            Method parse_file has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                        def parse_file file
                            begin
                                puts "[*] Parsing #{file}..."
                                tstart = Time.new
            
            
            Severity: Minor
            Found in lib/risu/cli/application.rb - About 1 hr to fix

              There are no issues that match your filters.

              Category
              Status