smalruby/smalruby-editor

View on GitHub

Showing 47 of 47 total issues

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

  module Block
    class MotionSelfAngle < Value
      include CharacterOperation

      blocknize '^\s*' + CHAR_RE + 'angle\s*$',
Severity: Major
Found in app/models/concerns/ruby_to_block/block/motion_self_angle.rb and 3 other locations - About 55 mins to fix
app/models/concerns/ruby_to_block/block/motion_self_x.rb on lines 2..19
app/models/concerns/ruby_to_block/block/motion_self_y.rb on lines 2..19
app/models/concerns/ruby_to_block/block/sensing_reach_wall.rb on lines 3..20

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

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

  module Block
    class MotionChangeXBy < CharacterMethodCall
      blocknize '^\s*' + CHAR_RE + 'x\s*\+=\s*(\S+)\s*$',
                statement: true, inline: true

Severity: Minor
Found in app/models/concerns/ruby_to_block/block/motion_change_x_by.rb and 1 other location - About 55 mins to fix
app/models/concerns/ruby_to_block/block/motion_change_y_by.rb on lines 3..16

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

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

  def to_blocks
    fail if data == '__FAIL__'

    context = Context.new(data.lines)
    while (line = context.next_line)
Severity: Minor
Found in app/models/concerns/ruby_to_block.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 blocknize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def self.blocknize(regexp, options = {})
        klass = (class << self; self; end)
        klass.instance_eval do
          define_method(:regexp_string) do
            regexp
Severity: Minor
Found in app/models/concerns/ruby_to_block/block/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

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

  module Block
    class MotionSetX < CharacterMethodCall
      blocknize '^\s*' + CHAR_RE + 'x\s*=\s*(\S+)\s*$',
                statement: true, inline: true

Severity: Major
Found in app/models/concerns/ruby_to_block/block/motion_set_x.rb and 4 other locations - About 35 mins to fix
app/models/concerns/ruby_to_block/block/motion_move.rb on lines 3..11
app/models/concerns/ruby_to_block/block/motion_set_angle.rb on lines 3..11
app/models/concerns/ruby_to_block/block/motion_set_y.rb on lines 3..11
app/models/concerns/ruby_to_block/block/sound_play.rb on lines 3..11

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

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

  module Block
    class HardwareLedTurnOn < CharacterMethodCall
      blocknize '^\s*' + CHAR_RE + 'led\("(D(?:[2-9]|1[0-3]))"\).turn_on\s*$',
                statement: true

app/models/concerns/ruby_to_block/block/hardware_led_turn_off.rb on lines 3..12
app/models/concerns/ruby_to_block/block/motion_turn_xy.rb on lines 3..11

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

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

  module Block
    class MotionMove < CharacterMethodCall
      blocknize '^\s*' + CHAR_RE + 'move\((.+)\)\s*$',
                statement: true, inline: true

Severity: Major
Found in app/models/concerns/ruby_to_block/block/motion_move.rb and 4 other locations - About 35 mins to fix
app/models/concerns/ruby_to_block/block/motion_set_angle.rb on lines 3..11
app/models/concerns/ruby_to_block/block/motion_set_x.rb on lines 3..11
app/models/concerns/ruby_to_block/block/motion_set_y.rb on lines 3..11
app/models/concerns/ruby_to_block/block/sound_play.rb on lines 3..11

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

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

  module Block
    class MotionSetAngle < CharacterMethodCall
      blocknize '^\s*' + CHAR_RE + 'angle\s*=\s*(\S+)\s*$',
                statement: true, inline: true

Severity: Major
Found in app/models/concerns/ruby_to_block/block/motion_set_angle.rb and 4 other locations - About 35 mins to fix
app/models/concerns/ruby_to_block/block/motion_move.rb on lines 3..11
app/models/concerns/ruby_to_block/block/motion_set_x.rb on lines 3..11
app/models/concerns/ruby_to_block/block/motion_set_y.rb on lines 3..11
app/models/concerns/ruby_to_block/block/sound_play.rb on lines 3..11

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

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

  module Block
    class MotionTurnXy < CharacterMethodCall
      blocknize '^\s*' + CHAR_RE + 'turn_([xy])\s*$', statement: true

      def self.process_match_data(md, context)
Severity: Minor
Found in app/models/concerns/ruby_to_block/block/motion_turn_xy.rb and 2 other locations - About 35 mins to fix
app/models/concerns/ruby_to_block/block/hardware_led_turn_off.rb on lines 3..12
app/models/concerns/ruby_to_block/block/hardware_led_turn_on.rb on lines 3..12

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

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

  module Block
    class HardwareLedTurnOff < CharacterMethodCall
      blocknize '^\s*' + CHAR_RE + 'led\("(D(?:[2-9]|1[0-3]))"\).turn_off\s*$',
                statement: true

app/models/concerns/ruby_to_block/block/hardware_led_turn_on.rb on lines 3..12
app/models/concerns/ruby_to_block/block/motion_turn_xy.rb on lines 3..11

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

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

  module Block
    class MotionSetY < CharacterMethodCall
      blocknize '^\s*' + CHAR_RE + 'y\s*=\s*(\S+)\s*$',
                statement: true, inline: true

Severity: Major
Found in app/models/concerns/ruby_to_block/block/motion_set_y.rb and 4 other locations - About 35 mins to fix
app/models/concerns/ruby_to_block/block/motion_move.rb on lines 3..11
app/models/concerns/ruby_to_block/block/motion_set_angle.rb on lines 3..11
app/models/concerns/ruby_to_block/block/motion_set_x.rb on lines 3..11
app/models/concerns/ruby_to_block/block/sound_play.rb on lines 3..11

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

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

  module Block
    class SoundPlay < CharacterMethodCall
      blocknize '^\s*' + CHAR_RE + 'play\(name:\s*(.+)\)\s*$',
                statement: true, inline: true

Severity: Major
Found in app/models/concerns/ruby_to_block/block/sound_play.rb and 4 other locations - About 35 mins to fix
app/models/concerns/ruby_to_block/block/motion_move.rb on lines 3..11
app/models/concerns/ruby_to_block/block/motion_set_angle.rb on lines 3..11
app/models/concerns/ruby_to_block/block/motion_set_x.rb on lines 3..11
app/models/concerns/ruby_to_block/block/motion_set_y.rb on lines 3..11

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

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

  module Block
    class ControlSleep < Base
      blocknize '^\s*sleep\((.+)\)\s*$', statement: true, inline: true

      def self.process_match_data(md, context)
Severity: Minor
Found in app/models/concerns/ruby_to_block/block/control_sleep.rb and 1 other location - About 30 mins to fix
app/models/concerns/ruby_to_block/block/ruby_p.rb on lines 3..15

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

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

  module Block
    class RubyP < CharacterMethodCall
      blocknize '^\s*p\((.+)\)\s*$',
                statement: true, inline: true

Severity: Minor
Found in app/models/concerns/ruby_to_block/block/ruby_p.rb and 1 other location - About 30 mins to fix
app/models/concerns/ruby_to_block/block/control_sleep.rb on lines 3..14

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

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

      def self.process_value_string(context, block, string, name)
        # HACK: 最初と最後の括弧を取り除く
        string = string[1..-2] while string[0] == '(' && string[-1] == ')'

        value_md = Block.value_regexp.match(string)
Severity: Minor
Found in app/models/concerns/ruby_to_block/block/base.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 standalone? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def standalone?
    return false if Rails.env == 'production'
    return true if Rails.env == 'standalone'

    if Rails.env != 'test' &&
Severity: Minor
Found in app/controllers/application_controller.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 2 locations. Consider refactoring.
Open

  module Block
    class EventsOnClick < CharacterEvent
      blocknize '^\s*' + CHAR_RE + 'on\(:click\)\s+do\s*$',
                statement: true, indent: true

Severity: Minor
Found in app/models/concerns/ruby_to_block/block/events_on_click.rb and 1 other location - About 25 mins to fix
app/models/concerns/ruby_to_block/block/events_on_start.rb on lines 2..10

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

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

    def add_block(block)
      if current_block
        # HACK: コメントは下の行に関係することが多いため対象外としている
        if current_block.type == 'character_new' &&
            block.type != 'character_new' && block.type != 'ruby_comment'
Severity: Minor
Found in app/models/concerns/ruby_to_block/context.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 make_remix_filename has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.make_remix_filename(home_dir, filename)
    home_dir = Pathname(home_dir).expand_path
    filename = filename.dup
    ext = filename.slice!(/\.rb(\.xml)?$/)
    filename.slice!(/(_remix(\d+)?)+$/)
Severity: Minor
Found in app/models/source_code.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

Function getRbxmlFilename has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  getRbxmlFilename: function() {
    var filename = this.get('filename');
    if (filename.match(/\.rb\.xml$/)) {
      return filename;
    }
Severity: Minor
Found in app/assets/javascripts/models/source_code.js - 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