armandofox/audience1st

View on GitHub
app/models/seatmap.rb

Summary

Maintainability
A
25 mins
Test Coverage
A
92%

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

  def self.seatmap_and_unavailable_seats_as_json(showdate, restrict_to_zone: nil, selected: [], is_boxoffice: false)
    return Seatmap::AsJson.empty unless (sm = showdate.seatmap)
    map = Seatmap::AsJson.new(sm)
    map.selected = selected
    map.holdback = showdate.house_seats.sort
Severity: Minor
Found in app/models/seatmap.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

Useless assignment to variable - map_unavailable.
Open

    map.selected = map.holdback = map_unavailable = []
Severity: Minor
Found in app/models/seatmap.rb by rubocop

This cop checks for every useless assignment to local variable in every scope. The basic idea for this cop was from the warning of ruby -cw:

assigned but unused variable - foo

Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.

Example:

# bad

def some_method
  some_var = 1
  do_something
end

Example:

# good

def some_method
  some_var = 1
  do_something(some_var)
end

Do not use prefix _ for a variable that is used.
Open

      _holdback = @holdback.compact.map { |num| seatmap.hover_label_with_zone(num) }.to_json
Severity: Minor
Found in app/models/seatmap.rb by rubocop

This cop checks for underscore-prefixed variables that are actually used.

Example:

# bad

[1, 2, 3].each do |_num|
  do_something(_num)
end

Example:

# good

[1, 2, 3].each do |num|
  do_something(num)
end

Example:

# good

[1, 2, 3].each do |_num|
  do_something # not using `_num`
end

Do not use prefix _ for a variable that is used.
Open

      _selected = @selected.compact.map { |num| seatmap.hover_label_with_zone(num) }.to_json
Severity: Minor
Found in app/models/seatmap.rb by rubocop

This cop checks for underscore-prefixed variables that are actually used.

Example:

# bad

[1, 2, 3].each do |_num|
  do_something(_num)
end

Example:

# good

[1, 2, 3].each do |num|
  do_something(num)
end

Example:

# good

[1, 2, 3].each do |_num|
  do_something # not using `_num`
end

Do not use prefix _ for a variable that is used.
Open

      _seatmap = seatmap.json
Severity: Minor
Found in app/models/seatmap.rb by rubocop

This cop checks for underscore-prefixed variables that are actually used.

Example:

# bad

[1, 2, 3].each do |_num|
  do_something(_num)
end

Example:

# good

[1, 2, 3].each do |num|
  do_something(num)
end

Example:

# good

[1, 2, 3].each do |_num|
  do_something # not using `_num`
end

Do not use prefix _ for a variable that is used.
Open

      _unavailable = @unavailable.compact.map { |num| seatmap.hover_label_with_zone(num) }.to_json
Severity: Minor
Found in app/models/seatmap.rb by rubocop

This cop checks for underscore-prefixed variables that are actually used.

Example:

# bad

[1, 2, 3].each do |_num|
  do_something(_num)
end

Example:

# good

[1, 2, 3].each do |num|
  do_something(num)
end

Example:

# good

[1, 2, 3].each do |_num|
  do_something # not using `_num`
end

There are no issues that match your filters.

Category
Status