hanami/hanami

View on GitHub

Showing 25 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

                        Identical blocks of code found in 3 locations. Consider refactoring.
                        Open

                                  def assert_valid_app!(context)
                                    return if project.app?(context)
                        
                                    existing_apps = project.apps.map { |name| "`#{name}'" }.join(' ')
                                    warn "`#{context.app}' is not a valid APP. Please specify one of: #{existing_apps}"
                        Severity: Minor
                        Found in lib/hanami/cli/commands/generate/action.rb and 2 other locations - About 25 mins to fix
                        lib/hanami/cli/commands/destroy/action.rb on lines 41..46
                        lib/hanami/cli/commands/destroy/app.rb on lines 42..47

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 29.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 3 locations. Consider refactoring.
                        Open

                                  def assert_valid_app!(context)
                                    return if project.app?(context)
                        
                                    existing_apps = project.apps.map { |name| "`#{name}'" }.join(' ')
                                    warn "`#{context.app}' is not a valid APP. Please specify one of: #{existing_apps}"
                        Severity: Minor
                        Found in lib/hanami/cli/commands/destroy/app.rb and 2 other locations - About 25 mins to fix
                        lib/hanami/cli/commands/destroy/action.rb on lines 41..46
                        lib/hanami/cli/commands/generate/action.rb on lines 144..149

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 29.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 3 locations. Consider refactoring.
                        Open

                                  def assert_valid_app!(context)
                                    return if project.app?(context)
                        
                                    existing_apps = project.apps.map { |name| "`#{name}'" }.join(' ')
                                    warn "`#{context.app}' is not a valid APP. Please specify one of: #{existing_apps}"
                        Severity: Minor
                        Found in lib/hanami/cli/commands/destroy/action.rb and 2 other locations - About 25 mins to fix
                        lib/hanami/cli/commands/destroy/app.rb on lines 42..47
                        lib/hanami/cli/commands/generate/action.rb on lines 144..149

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 29.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Similar blocks of code found in 4 locations. Consider refactoring.
                        Open

                          class CLI
                            module Commands
                              module Db
                                # @since 1.1.0
                                # @api private
                        Severity: Minor
                        Found in lib/hanami/cli/commands/db/prepare.rb and 3 other locations - About 20 mins to fix
                        lib/hanami/cli/commands/db/apply.rb on lines 2..26
                        lib/hanami/cli/commands/db/create.rb on lines 2..26
                        lib/hanami/cli/commands/db/drop.rb on lines 2..26

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 28.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Severity
                        Category
                        Status
                        Source
                        Language