Charyf/charyf-core

View on GitHub

Showing 29 of 29 total issues

Method constantize has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

  def constantize
    camel_cased_word = self

    names = camel_cased_word.split('::')

Severity: Minor
Found in lib/charyf/support/string.rb - About 3 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

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

    class AppBase < Base # :nodoc:
      add_shebang_option!

      argument :app_path, type: :string

Severity: Minor
Found in lib/charyf/utils/generators/app_base.rb - About 2 hrs to fix

    Class Base has 23 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Base < Thor::Group
          include Thor::Actions
          include Charyf::Generators::Actions
    
          add_runtime_options!
    Severity: Minor
    Found in lib/charyf/utils/generator/base.rb - About 2 hrs to fix

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

        def deep_merge!(other_hash, options = {}, &block)
          other_hash.each_pair do |current_key, other_value|
            this_value = self[current_key]
      
            self[current_key] = if this_value.is_a?(Hash) && other_value.is_a?(Hash)
      Severity: Minor
      Found in lib/charyf/support/hash.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 gem has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

            def gem(*args)
              options = args.last.is_a?(Hash) ? args.pop : {}
              name, *versions = args
      
              # Set the message to be shown in logs. Uses the git repo if one is given,
      Severity: Minor
      Found in lib/charyf/utils/generator/actions.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 hook_for has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

            def self.hook_for(*names, &block)
              options = names.last.is_a?(Hash) ? names.pop : {}
              in_base = options.delete(:in) || base_name
              as_hook = options.delete(:as) || generator_name
      
      
      Severity: Minor
      Found in lib/charyf/utils/generator/base.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 find_by_namespace has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def find_by_namespace(name, base = nil, context = nil) #:nodoc:
              lookups = []
              lookups << "#{base}:#{name}"    if base
              lookups << "#{name}:#{context}" if context
      
      
      Severity: Minor
      Found in lib/charyf/utils/generators.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 build has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

              def build
                _states.each do |state_name, state|
                  events = _events(state_name)
                  raise InvalidDefinition.new("No transitions from state #{state_name}") if events.empty? && !state[:final]
      
      
      Severity: Minor
      Found in lib/charyf/utils/machine.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 prepare_for_invocation has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def self.prepare_for_invocation(name, value) #:nodoc:
              return super unless value.is_a?(String) || value.is_a?(Symbol) #|| value.is_a?(Array)
      
              if value && constants = hooks[name]
                value = name if TrueClass === value
      Severity: Minor
      Found in lib/charyf/utils/generator/base.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 exec_app has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def exec_app
            original_cwd = Dir.pwd
      
            loop do
              if exe = find_executable
      Severity: Minor
      Found in lib/charyf/utils/app_loader.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

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

            def bundle_command(command)
              say_status :run, "bundle #{command}"
      
              # We are going to shell out rather than invoking Bundler::CLI.new(command)
              # because `charyf new` loads the Thor gem and on the other hand bundler uses
      Severity: Minor
      Found in lib/charyf/utils/generators/app_base.rb and 1 other location - About 45 mins to fix
      lib/charyf/utils/generators/app_base.rb on lines 258..269

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

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

            def charyf_command(command)
              say_status :run, "charyf #{command}"
      
              _charyf_command = Gem.bin_path("charyf", "charyf")
      
      
      Severity: Minor
      Found in lib/charyf/utils/generators/app_base.rb and 1 other location - About 45 mins to fix
      lib/charyf/utils/generators/app_base.rb on lines 234..253

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

      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 invoke_fallbacks_for has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def invoke_fallbacks_for(name, base)
              return nil unless base && fallbacks[base.to_sym]
              invoked_fallbacks = []
      
              Array(fallbacks[base.to_sym]).each do |fallback|
      Severity: Minor
      Found in lib/charyf/utils/generators.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 create_root_files has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def create_root_files
                build(:readme)
                build(:gitignore)   unless options[:skip_git]
                build(:version_control)
      
      
      Severity: Minor
      Found in lib/charyf/utils/generators/app/app_generator.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 invoke has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def invoke(namespace, args = ARGV, config = {})
              names = namespace.to_s.split(":")
              if klass = find_by_namespace(names.pop, names.any? && names.join(":"))
                args << "--help" if args.empty? && klass.arguments.any?(&:required?)
                klass.start(args, config)
      Severity: Minor
      Found in lib/charyf/utils/generators.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 class_collisions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def class_collisions(*class_names)
              return unless behavior == :invoke
      
              class_names.flatten.each do |class_name|
                class_name = class_name.to_s
      Severity: Minor
      Found in lib/charyf/utils/generator/base.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 log has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def log(*args) # :doc:
              if args.size == 1
                say args.first.to_s unless options.quiet?
              else
                args << (behavior == :invoke ? :green : :red)
      Severity: Minor
      Found in lib/charyf/utils/generator/actions.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 find_root_with_flag has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.find_root_with_flag(flag, root_path, default: nil, namespace: 'charyf') #:nodoc:
            root_path = Pathname.new(root_path)
      
            root_path = root_path.join(namespace) if namespace && File.directory?(root_path.join(namespace))
      
      
      Severity: Minor
      Found in lib/charyf/utils/utils.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(name, version, comment, options = {}, commented_out = false)
      Severity: Minor
      Found in lib/charyf/utils/generators/app_base.rb - About 35 mins to fix

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

              def method_missing(method, *args)
                method = method.to_s.sub(/=$/, "").to_sym
        
                return @options[method] if args.empty?
        
        
        Severity: Minor
        Found in lib/charyf/utils/configuration.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

        Severity
        Category
        Status
        Source
        Language