YorickPeterse/ruby-lint

View on GitHub

Showing 2,162 of 2,162 total issues

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

  defs.define_constant('Sprockets::SafetyColons') do |klass|
    klass.inherits(defs.constant_proxy('Tilt::Template', RubyLint.registry))

    klass.define_instance_method('evaluate') do |method|
      method.define_argument('context')
Severity: Major
Found in lib/ruby-lint/definitions/rails/sprockets.rb and 4 other locations - About 25 mins to fix
lib/ruby-lint/definitions/core/irb.rb on lines 271..280
lib/ruby-lint/definitions/gems/minitest.rb on lines 439..448
lib/ruby-lint/definitions/rails/action_controller.rb on lines 831..840
lib/ruby-lint/definitions/rails/sprockets.rb on lines 377..386

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

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

  defs.define_constant('ActiveRecord::SchemaMigration::HasManyAssociation') do |klass|
    klass.inherits(defs.constant_proxy('ActiveRecord::Associations::CollectionAssociation', RubyLint.registry))

    klass.define_instance_method('handle_dependency')

Severity: Major
Found in lib/ruby-lint/definitions/rails/active_record.rb and 5 other locations - About 25 mins to fix
lib/ruby-lint/definitions/rails/active_model.rb on lines 1353..1361
lib/ruby-lint/definitions/rails/active_record.rb on lines 590..598
lib/ruby-lint/definitions/rails/active_record.rb on lines 2442..2450
lib/ruby-lint/definitions/rails/active_record.rb on lines 2473..2481
lib/ruby-lint/definitions/rails/active_record.rb on lines 10087..10095

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

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

  defs.define_constant('ActiveModel::Validations::FormatValidator') do |klass|
    klass.inherits(defs.constant_proxy('ActiveModel::EachValidator', RubyLint.registry))

    klass.define_instance_method('check_validity!')

Severity: Major
Found in lib/ruby-lint/definitions/rails/active_model.rb and 5 other locations - About 25 mins to fix
lib/ruby-lint/definitions/rails/active_record.rb on lines 590..598
lib/ruby-lint/definitions/rails/active_record.rb on lines 2442..2450
lib/ruby-lint/definitions/rails/active_record.rb on lines 2473..2481
lib/ruby-lint/definitions/rails/active_record.rb on lines 10087..10095
lib/ruby-lint/definitions/rails/active_record.rb on lines 10123..10131

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

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

  defs.define_constant('ActiveRecord::Associations::HasManyAssociation') do |klass|
    klass.inherits(defs.constant_proxy('ActiveRecord::Associations::CollectionAssociation', RubyLint.registry))

    klass.define_instance_method('handle_dependency')

Severity: Major
Found in lib/ruby-lint/definitions/rails/active_record.rb and 5 other locations - About 25 mins to fix
lib/ruby-lint/definitions/rails/active_model.rb on lines 1353..1361
lib/ruby-lint/definitions/rails/active_record.rb on lines 2442..2450
lib/ruby-lint/definitions/rails/active_record.rb on lines 2473..2481
lib/ruby-lint/definitions/rails/active_record.rb on lines 10087..10095
lib/ruby-lint/definitions/rails/active_record.rb on lines 10123..10131

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

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

  defs.define_constant('Sprockets::CharsetNormalizer') do |klass|
    klass.inherits(defs.constant_proxy('Tilt::Template', RubyLint.registry))

    klass.define_instance_method('evaluate') do |method|
      method.define_argument('context')
Severity: Major
Found in lib/ruby-lint/definitions/rails/sprockets.rb and 4 other locations - About 25 mins to fix
lib/ruby-lint/definitions/core/irb.rb on lines 271..280
lib/ruby-lint/definitions/gems/minitest.rb on lines 439..448
lib/ruby-lint/definitions/rails/action_controller.rb on lines 831..840
lib/ruby-lint/definitions/rails/sprockets.rb on lines 1612..1621

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

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

  defs.define_constant('Minitest::Parallel::Test::ClassMethods') do |klass|
    klass.inherits(defs.constant_proxy('Object', RubyLint.registry))

    klass.define_instance_method('run_one_method') do |method|
      method.define_argument('klass')
Severity: Major
Found in lib/ruby-lint/definitions/gems/minitest.rb and 4 other locations - About 25 mins to fix
lib/ruby-lint/definitions/core/irb.rb on lines 271..280
lib/ruby-lint/definitions/rails/action_controller.rb on lines 831..840
lib/ruby-lint/definitions/rails/sprockets.rb on lines 377..386
lib/ruby-lint/definitions/rails/sprockets.rb on lines 1612..1621

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

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

  defs.define_constant('Nokogiri::HTML::Document::EncodingReader::SAXHandler') do |klass|
    klass.inherits(defs.constant_proxy('Nokogiri::XML::SAX::Document', RubyLint.registry))

    klass.define_instance_method('encoding')

Severity: Minor
Found in lib/ruby-lint/definitions/gems/nokogiri.rb and 2 other locations - About 25 mins to fix
lib/ruby-lint/definitions/core/resolv.rb on lines 635..644
lib/ruby-lint/definitions/rails/sprockets.rb on lines 1664..1673

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

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

  defs.define_constant('ActiveModel::Translation') do |klass|
    klass.inherits(defs.constant_proxy('Object', RubyLint.registry))

    klass.define_instance_method('human_attribute_name') do |method|
      method.define_argument('attribute')
Severity: Minor
Found in lib/ruby-lint/definitions/rails/active_model.rb and 2 other locations - About 25 mins to fix
lib/ruby-lint/definitions/rails/action_view.rb on lines 5355..5365
lib/ruby-lint/definitions/rails/action_view.rb on lines 6615..6625

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

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

  defs.define_constant('ActionView::TestCase::Behavior::Locals') do |klass|
    klass.inherits(defs.constant_proxy('Object', RubyLint.registry))

    klass.define_instance_method('render') do |method|
      method.define_optional_argument('options')
Severity: Minor
Found in lib/ruby-lint/definitions/rails/action_view.rb and 2 other locations - About 25 mins to fix
lib/ruby-lint/definitions/rails/action_view.rb on lines 6615..6625
lib/ruby-lint/definitions/rails/active_model.rb on lines 1144..1154

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

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

  defs.define_constant('Sprockets::StaticAsset') do |klass|
    klass.inherits(defs.constant_proxy('Sprockets::Asset', RubyLint.registry))

    klass.define_instance_method('source')

Severity: Minor
Found in lib/ruby-lint/definitions/rails/sprockets.rb and 2 other locations - About 25 mins to fix
lib/ruby-lint/definitions/core/resolv.rb on lines 635..644
lib/ruby-lint/definitions/gems/nokogiri.rb on lines 935..944

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

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

  defs.define_constant('ActionView::TestCase::Locals') do |klass|
    klass.inherits(defs.constant_proxy('Object', RubyLint.registry))

    klass.define_instance_method('render') do |method|
      method.define_optional_argument('options')
Severity: Minor
Found in lib/ruby-lint/definitions/rails/action_view.rb and 2 other locations - About 25 mins to fix
lib/ruby-lint/definitions/rails/action_view.rb on lines 5355..5365
lib/ruby-lint/definitions/rails/active_model.rb on lines 1144..1154

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

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

  defs.define_constant('ActionController::Caching') do |klass|
    klass.inherits(defs.constant_proxy('Object', RubyLint.registry))

    klass.define_instance_method('cache') do |method|
      method.define_argument('key')
Severity: Major
Found in lib/ruby-lint/definitions/rails/action_controller.rb and 4 other locations - About 25 mins to fix
lib/ruby-lint/definitions/core/irb.rb on lines 271..280
lib/ruby-lint/definitions/gems/minitest.rb on lines 439..448
lib/ruby-lint/definitions/rails/sprockets.rb on lines 377..386
lib/ruby-lint/definitions/rails/sprockets.rb on lines 1612..1621

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

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

  defs.define_constant('Resolv::DNS::Requester') do |klass|
    klass.inherits(defs.constant_proxy('Object', RubyLint.registry))

    klass.define_instance_method('close')

Severity: Minor
Found in lib/ruby-lint/definitions/core/resolv.rb and 2 other locations - About 25 mins to fix
lib/ruby-lint/definitions/gems/nokogiri.rb on lines 935..944
lib/ruby-lint/definitions/rails/sprockets.rb on lines 1664..1673

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

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

      def on_send(node)
        receiver, name, _  = *node

        receiver = unpack_block(receiver)
        name     = name.to_s
Severity: Minor
Found in lib/ruby-lint/analysis/undefined_methods.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 execute_callback has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def execute_callback(name, *args)
      return unless respond_to?(name)

      unless arity_cache.key?(name)
        arity_cache[name] = method(name).arity
Severity: Minor
Found in lib/ruby-lint/iterator.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 assign_variable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def assign_variable(type, name, value, node)
      scope    = assignment_scope(type)
      variable = scope.lookup(type, name)

      # If there's already a variable we'll just update it.
Severity: Minor
Found in lib/ruby-lint/virtual_machine.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 push_variable_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def push_variable_value(node)
      return if value_stack.empty? || @ignored_nodes.include?(node)

      definition = definition_for_node(node)

Severity: Minor
Found in lib/ruby-lint/virtual_machine.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 determine_parent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def determine_parent(parent, type, name, exclude = [])
        if parent.type == type and parent.name == name
          parent_definition = parent
        else
          exclude = exclude + [self] unless exclude.include?(self)
Severity: Minor
Found in lib/ruby-lint/definition/ruby_object.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

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

  defs.define_constant('Syck::EngineManager') do |klass|
    klass.inherits(defs.constant_proxy('Object', RubyLint.registry))

    klass.define_instance_method('initialize')

Severity: Major
Found in lib/ruby-lint/definitions/core/syck.rb and 5 other locations - About 25 mins to fix
lib/ruby-lint/definitions/gems/devise.rb on lines 1753..1763
lib/ruby-lint/definitions/gems/devise.rb on lines 1920..1930
lib/ruby-lint/definitions/gems/mongoid.rb on lines 2558..2568
lib/ruby-lint/definitions/gems/mongoid.rb on lines 8370..8380
lib/ruby-lint/definitions/gems/mongoid.rb on lines 8384..8394

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

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

  defs.define_constant('ActiveRecord::SchemaMigration::BelongsToAssociation') do |klass|
    klass.inherits(defs.constant_proxy('ActiveRecord::Associations::SingularAssociation', RubyLint.registry))

    klass.define_instance_method('handle_dependency')

Severity: Major
Found in lib/ruby-lint/definitions/rails/active_record.rb and 5 other locations - About 25 mins to fix
lib/ruby-lint/definitions/gems/celluloid.rb on lines 3299..3310
lib/ruby-lint/definitions/gems/celluloid.rb on lines 4463..4474
lib/ruby-lint/definitions/rails/active_record.rb on lines 411..422
lib/ruby-lint/definitions/rails/active_record.rb on lines 1937..1948
lib/ruby-lint/definitions/rails/active_support.rb on lines 1397..1408

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

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