ronin-rb/ronin-support

View on GitHub

Showing 197 of 197 total issues

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

  def self.aes_encrypt(path, block_size: 16384, output: nil, **kwargs,&block)
    cipher = Ronin::Support::Crypto.aes_cipher(direction: :encrypt, **kwargs)
    file   = File.open(path,'rb')

    return cipher.stream(file, block_size: block_size, output: output,&block)
Severity: Major
Found in lib/ronin/support/crypto/core_ext/file.rb and 5 other locations - About 30 mins to fix
lib/ronin/support/crypto/core_ext/file.rb on lines 411..415
lib/ronin/support/crypto/core_ext/file.rb on lines 464..468
lib/ronin/support/crypto/core_ext/file.rb on lines 517..521
lib/ronin/support/crypto/core_ext/file.rb on lines 570..574
lib/ronin/support/crypto/core_ext/file.rb on lines 623..627

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

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

  def self.aes256_decrypt(path, block_size: 16384, output: nil, **kwargs,&block)
    cipher = Ronin::Support::Crypto.aes256_cipher(direction: :decrypt, **kwargs)
    file   = File.open(path,'rb')

    return cipher.stream(file, block_size: block_size, output: output,&block)
Severity: Major
Found in lib/ronin/support/crypto/core_ext/file.rb and 5 other locations - About 30 mins to fix
lib/ronin/support/crypto/core_ext/file.rb on lines 355..359
lib/ronin/support/crypto/core_ext/file.rb on lines 411..415
lib/ronin/support/crypto/core_ext/file.rb on lines 464..468
lib/ronin/support/crypto/core_ext/file.rb on lines 517..521
lib/ronin/support/crypto/core_ext/file.rb on lines 570..574

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

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

  def self.aes128_decrypt(path, block_size: 16384, output: nil, **kwargs,&block)
    cipher = Ronin::Support::Crypto.aes128_cipher(direction: :decrypt, **kwargs)
    file   = File.open(path,'rb')

    return cipher.stream(file, block_size: block_size, output: output,&block)
Severity: Major
Found in lib/ronin/support/crypto/core_ext/file.rb and 5 other locations - About 30 mins to fix
lib/ronin/support/crypto/core_ext/file.rb on lines 355..359
lib/ronin/support/crypto/core_ext/file.rb on lines 411..415
lib/ronin/support/crypto/core_ext/file.rb on lines 464..468
lib/ronin/support/crypto/core_ext/file.rb on lines 570..574
lib/ronin/support/crypto/core_ext/file.rb on lines 623..627

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

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

  def self.aes_decrypt(path, block_size: 16384, output: nil, **kwargs,&block)
    cipher = Ronin::Support::Crypto.aes_cipher(direction: :decrypt, **kwargs)
    file   = File.open(path,'rb')

    return cipher.stream(file, block_size: block_size, output: output,&block)
Severity: Major
Found in lib/ronin/support/crypto/core_ext/file.rb and 5 other locations - About 30 mins to fix
lib/ronin/support/crypto/core_ext/file.rb on lines 355..359
lib/ronin/support/crypto/core_ext/file.rb on lines 464..468
lib/ronin/support/crypto/core_ext/file.rb on lines 517..521
lib/ronin/support/crypto/core_ext/file.rb on lines 570..574
lib/ronin/support/crypto/core_ext/file.rb on lines 623..627

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

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 self.escape(data,**kwargs)
          escaped = String.new

          if data.valid_encoding?
            data.each_codepoint do |codepoint|
Severity: Minor
Found in lib/ronin/support/encoding/xml.rb and 1 other location - About 30 mins to fix
lib/ronin/support/encoding/xml.rb on lines 216..229

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

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

  def self.aes256_encrypt(path, block_size: 16384, output: nil, **kwargs,&block)
    cipher = Ronin::Support::Crypto.aes256_cipher(direction: :encrypt, **kwargs)
    file   = File.open(path,'rb')

    return cipher.stream(file, block_size: block_size, output: output,&block)
Severity: Major
Found in lib/ronin/support/crypto/core_ext/file.rb and 5 other locations - About 30 mins to fix
lib/ronin/support/crypto/core_ext/file.rb on lines 355..359
lib/ronin/support/crypto/core_ext/file.rb on lines 411..415
lib/ronin/support/crypto/core_ext/file.rb on lines 464..468
lib/ronin/support/crypto/core_ext/file.rb on lines 517..521
lib/ronin/support/crypto/core_ext/file.rb on lines 623..627

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

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 self.encode(data,**kwargs)
          encoded = String.new

          if data.valid_encoding?
            data.each_codepoint do |codepoint|
Severity: Minor
Found in lib/ronin/support/encoding/xml.rb and 1 other location - About 30 mins to fix
lib/ronin/support/encoding/xml.rb on lines 274..287

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

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 self.encode(data, mode: nil)
          case mode
          when :strict   then ::Base64.strict_encode64(data)
          when :url_safe then ::Base64.urlsafe_encode64(data)
          when nil       then ::Base64.encode64(data)
Severity: Minor
Found in lib/ronin/support/encoding/base64.rb and 1 other location - About 25 mins to fix
lib/ronin/support/encoding/base64.rb on lines 71..77

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

        def self.decode(data, mode: nil)
          case mode
          when :strict   then ::Base64.strict_decode64(data)
          when :url_safe then ::Base64.urlsafe_decode64(data)
          when nil       then ::Base64.decode64(data)
Severity: Minor
Found in lib/ronin/support/encoding/base64.rb and 1 other location - About 25 mins to fix
lib/ronin/support/encoding/base64.rb on lines 49..55

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

                typedef :long_long, :intptr_t
                typedef :long_long, :_pid_t
                typedef :long_long, :pid_t
                typedef :long_long, :ptrdiff_t
                typedef :ulong_long, :rsize_t
Severity: Minor
Found in lib/ronin/support/binary/ctypes/os/windows.rb and 1 other location - About 25 mins to fix
lib/ronin/support/binary/ctypes/os/windows.rb on lines 108..118

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

                typedef :int, :intptr_t
                typedef :int, :_pid_t
                typedef :int, :pid_t
                typedef :int, :ptrdiff_t
                typedef :uint, :rsize_t
Severity: Minor
Found in lib/ronin/support/binary/ctypes/os/windows.rb and 1 other location - About 25 mins to fix
lib/ronin/support/binary/ctypes/os/windows.rb on lines 97..107

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

        def self.unescape(data)
          unescaped = String.new
          scanner   = StringScanner.new(data)

          until scanner.eos?
Severity: Minor
Found in lib/ronin/support/encoding/shell.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 magenta has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def magenta(string=nil)
          if string
            if $stdout.tty? then "#{MAGENTA}#{string}#{RESET_COLOR}"
            else                 string
            end
Severity: Minor
Found in lib/ronin/support/cli/ansi.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 build has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

          def self.build(fields, alignment: nil)
            members       = {}
            max_size      = 0
            max_alignment = 0

Severity: Minor
Found in lib/ronin/support/binary/ctypes/union_type.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 each_substring has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def each_substring(min=1,&block)
    return enum_for(__method__,min) unless block

    (0..(length - min)).each do |i|
      ((i + min)..length).each do |j|
Severity: Minor
Found in lib/ronin/support/core_ext/string.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 yellow has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def yellow(string=nil)
          if string
            if $stdout.tty? then "#{YELLOW}#{string}#{RESET_COLOR}"
            else                 string
            end
Severity: Minor
Found in lib/ronin/support/cli/ansi.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 blue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def blue(string=nil)
          if string
            if $stdout.tty? then "#{BLUE}#{string}#{RESET_COLOR}"
            else                 string
            end
Severity: Minor
Found in lib/ronin/support/cli/ansi.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 [] has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def [](name)
          if (member = @type.members[name])
            case member.type
            when CTypes::UnboundedArrayType
              # XXX: but how do we handle an unbounded array of structs?
Severity: Minor
Found in lib/ronin/support/binary/struct.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 unescape has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def self.unescape(data)
          unescaped = String.new(encoding: Encoding::UTF_8)

          data.scan(/[\\%]u[0-9a-fA-F]{1,4}|[\\%][0-9a-fA-F]{1,2}|\\[btnfr\'\"\\]|./) do |c|
            unescaped << BACKSLASHED_CHARS.fetch(c) do
Severity: Minor
Found in lib/ronin/support/encoding/js.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 green has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def green(string=nil)
          if string
            if $stdout.tty? then "#{GREEN}#{string}#{RESET_COLOR}"
            else                 string
            end
Severity: Minor
Found in lib/ronin/support/cli/ansi.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