hanami/hanami

View on GitHub

Showing 16 of 25 total issues

Class CLI has 66 methods (exceeds 20 allowed). Consider refactoring.
Open

  class CLI
    module Commands
      # @since 1.1.0
      # @api private
      module Project # rubocop:disable Metrics/ModuleLength
Severity: Major
Found in lib/hanami/cli/commands/project.rb - About 1 day to fix

    File new.rb has 341 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "hanami/cli/commands/generate/app"
    
    module Hanami
      # Hanami CLI
      #
    Severity: Minor
    Found in lib/hanami/cli/commands/new.rb - About 4 hrs to fix

      Class ApplicationConfiguration has 28 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class ApplicationConfiguration
          # @since 0.2.0
          # @api private
          #
          # @see Hanami::Configuration#ssl?
      Severity: Minor
      Found in lib/hanami/application_configuration.rb - About 3 hrs to fix

        Class Action has 25 methods (exceeds 20 allowed). Consider refactoring.
        Open

                class Action < Command
                  requires "environment"
        
                  desc "Generate an action for app"
        
        
        Severity: Minor
        Found in lib/hanami/cli/commands/generate/action.rb - About 2 hrs to fix

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

            class Environment
              # Global lock (used to serialize process of environment configuration)
              #
              # @since 0.8.0
              # @api private
          Severity: Minor
          Found in lib/hanami/environment.rb - About 2 hrs to fix

            File components.rb has 259 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require 'hanami/utils'
            
            module Hanami
              # Registered components
              #
            Severity: Minor
            Found in lib/hanami/components/components.rb - About 2 hrs to fix

              Method call has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      def call(project:, **options)
                        project_name = project
                        pwd = ::File.basename(Dir.pwd) if project == "."
                        project         = Utils::String.underscore(pwd || project)
                        database_config = DatabaseConfig.new(options[:database], project)
              Severity: Minor
              Found in lib/hanami/cli/commands/new.rb - About 1 hr to fix

                Method resolve has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        def self.resolve(app)
                          config    = app.configuration
                          namespace = app.namespace
                
                          unless namespace.const_defined?('Controller', false)
                Severity: Minor
                Found in lib/hanami/components/app/controller.rb - About 1 hr to fix

                  Method resolve has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                          def self.resolve(app)
                            config    = app.configuration
                            namespace = app.namespace
                  
                            unless namespace.const_defined?('Controller', false)
                  Severity: Minor
                  Found in lib/hanami/components/app/controller.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 generate_empty_directories has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          def generate_empty_directories(context)
                            source = templates.find(".gitkeep.erb")
                  
                            destination = project.keep(project.public_directory(context))
                            generate_file(source, destination, context)
                  Severity: Minor
                  Found in lib/hanami/cli/commands/new.rb - About 1 hr to fix

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

                            def generate_application_templates(context)
                              source      = templates.find("hanamirc.erb")
                              destination = project.hanamirc(context)
                              generate_file(source, destination, context)
                    
                    
                    Severity: Minor
                    Found in lib/hanami/cli/commands/new.rb - About 1 hr to fix

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

                              def generate_test_templates(context)
                                if context.test_framework.rspec?
                                  source      = templates.find("rspec", "Rakefile.erb")
                                  destination = project.rakefile(context)
                                  generate_file(source, destination, context)
                      Severity: Minor
                      Found in lib/hanami/cli/commands/new.rb - About 1 hr to fix

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

                            def port(value = nil)
                              if value
                                @port = Integer(value)
                              else
                                return @port if defined?(@port)
                        Severity: Minor
                        Found in lib/hanami/application_configuration.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 send_early_hints has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def send_early_hints(env)
                              return if Thread.current[CACHE_KEY].nil?
                        
                              Thread.current[CACHE_KEY].each_slice(BATCH_SIZE) do |slice|
                                link = slice.map do |asset, options|
                        Severity: Minor
                        Found in lib/hanami/early_hints.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_application_env_vars! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def set_application_env_vars!
                              DOTENV_FILES.each do |filename_format|
                                file = filename_format % { environment: environment }
                                next unless dotenv_applicable?(file)
                        
                        
                        Severity: Minor
                        Found in lib/hanami/environment.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 application_class has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def application_class
                              Hanami.configuration.apps do |app|
                                if app.host.nil?
                                  return app if @request_path.include?(app.path_prefix)
                                else
                        Severity: Minor
                        Found in lib/hanami/welcome.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