lib/opal/source_map/file.rb

Summary

Maintainability
A
25 mins
Test Coverage

Method fragments_by_line has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Wontfix

  def fragments_by_line
    raw_mappings = [[]]
    fragments.flat_map do |fragment|
      fragment_code = fragment.code
      splitter = /\r/.match?(fragment_code) ? /\r?\n/ : "\n"
Severity: Minor
Found in lib/opal/source_map/file.rb - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

  def segment_from_fragment(fragment, generated_column)
    source_index     = 0                          # always 0, we're dealing with a single file
    original_line    = (fragment.line || 0) - 1   # fragments have 1-based lines
    original_line    = 0 if original_line < 0     # line 0 (-1) for fragments in source maps will crash
                                                  # browsers devtools and the webpack build process
Severity: Minor
Found in lib/opal/source_map/file.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

There are no issues that match your filters.

Category
Status