ddd-ruby/rdm

View on GitHub

Showing 14 of 14 total issues

Method generate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def generate
        project_path      = @ignore_source_file ? @current_path : File.dirname(Rdm::SourceLocator.locate(@current_path))
        template_detector = Rdm::Templates::TemplateDetector.new(project_path)

        render_helper_path = "#{project_path}/.rdm/helpers/render_helper.rb"
Severity: Minor
Found in lib/rdm/handlers/template_handler.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 has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def generate
        project_path      = @ignore_source_file ? @current_path : File.dirname(Rdm::SourceLocator.locate(@current_path))
        template_detector = Rdm::Templates::TemplateDetector.new(project_path)

        render_helper_path = "#{project_path}/.rdm/helpers/render_helper.rb"
Severity: Minor
Found in lib/rdm/handlers/template_handler.rb - About 1 hr to fix

    Method compile has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

          def compile
            Rdm::SourceParser.read_and_init_source(Rdm::SourceLocator.locate(@project_path))
    
            @overwrite_directory ||= ->() { STDIN.gets.chomp.downcase == YES }
            @compile_path        ||= Rdm.settings.compile_path
    Severity: Minor
    Found in lib/rdm/cli/compile_package.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 compile has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def compile
            FileUtils.rm_rf(@compile_path) if Dir.exists?(@compile_path)
            FileUtils.mkdir_p(@compile_path)
    
            dependent_packages = Rdm::Handlers::DependenciesHandler.show_packages(
    Severity: Minor
    Found in lib/rdm/packages/compiler_service.rb - About 1 hr to fix

      Method draw has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def draw(pkg_name = @package_name, uniq_packages = [], self_predicate = '', child_predicate = '')
              raise Rdm::Errors::InvalidParams, "Type package name, ex: rdm gen.deps repository" if pkg_name.to_s.empty?
              raise Rdm::Errors::PackageHasNoDependencies, @package_name if source.packages[@package_name].local_dependencies.empty?
      
              node = [format(pkg_name, self_predicate)]
      Severity: Minor
      Found in lib/rdm/handlers/dependencies_handler.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 compile has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def compile
              FileUtils.rm_rf(@compile_path) if Dir.exists?(@compile_path)
              FileUtils.mkdir_p(@compile_path)
      
              dependent_packages = Rdm::Handlers::DependenciesHandler.show_packages(
      Severity: Minor
      Found in lib/rdm/packages/compiler_service.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 update_using_hash has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def update_using_hash(hash, scope: nil)
          scope ||= root_scope
      
          hash.each do |key, value|
            if value.is_a?(Hash)
      Severity: Minor
      Found in lib/rdm/config_manager.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 handle has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def handle
              @revision = 'HEAD' if @revision.nil? || @revision.empty?
      
              modified_packages = Rdm::Git::DiffManager
                .run(path: path, revision: revision)
      Severity: Minor
      Found in lib/rdm/handlers/diff_package_handler.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def initialize(package_name, current_path, path, locals, stdout)
      Severity: Minor
      Found in lib/rdm/cli/gen_package.rb - About 35 mins to fix

        Method init_and_set_env_variables has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def init_and_set_env_variables(source)
            return unless settings.read_setting(:env_file_name)
            
            unless File.exists?(env_file_path)
              @stdout.puts "WARNING! Environment file '#{settings.read_setting(:env_file_name)}' was not found. Please, add #{env_file_path} file..."
        Severity: Minor
        Found in lib/rdm/source_parser.rb - About 35 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 import_package has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def import_package(package_name, source:, group: nil)
            return imported_packages if imported_packages.include?(package_name.to_s)
            package = source.packages[package_name.to_s]
        
            raise "Can't find package with name: #{package_name}" if package.nil?
        Severity: Minor
        Found in lib/rdm/package_importer.rb - About 35 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 2 locations. Consider refactoring.
        Open

          module RenderHelper
            def camelize(string, uppercase_first_letter = true)
              if uppercase_first_letter
                string = string.sub(/^[a-z\d]*/) { $&.capitalize }
              else
        Severity: Minor
        Found in lib/rdm/templates/init/.rdm/helpers/render_helper.rb and 1 other location - About 35 mins to fix
        example/.rdm/helpers/render_helper.rb on lines 2..9

        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 34.

        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 2 locations. Consider refactoring.
        Open

          module RenderHelper
            def camelize(string, uppercase_first_letter = true)
              if uppercase_first_letter
                string = string.sub(/^[a-z\d]*/) { $&.capitalize }
              else
        Severity: Minor
        Found in example/.rdm/helpers/render_helper.rb and 1 other location - About 35 mins to fix
        lib/rdm/templates/init/.rdm/helpers/render_helper.rb on lines 2..9

        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 34.

        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

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

          def check_input_params!
            if @package_name
              unless is_package_included?(@package_name)
                exit_with_message(
                  view.package_not_found_message(@package_name, prepared_command_params)
        Severity: Minor
        Found in lib/rdm/spec_runner/runner.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