newtheatre/history-project

View on GitHub
_plugins/show.rb

Summary

Maintainability
D
2 days
Test Coverage

Class has too many lines. [255/250]
Open

  class ShowDataGenerator < Jekyll::Generator
    priority :high

    # From years.rb
    def years_by_slug
Severity: Minor
Found in _plugins/show.rb by rubocop

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method has too many lines. [64/30]
Open

    def generate_show(show)
      # Set year attributes
      show.data["year"] = get_show_year(show)
      show.data["year_page"] = get_show_year_page(show)

Severity: Minor
Found in _plugins/show.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method generate_show has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    def generate_show(show)
      # Set year attributes
      show.data["year"] = get_show_year(show)
      show.data["year_page"] = get_show_year_page(show)

Severity: Minor
Found in _plugins/show.rb - About 4 hrs 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

Cyclomatic complexity for generate_show is too high. [23/6]
Open

    def generate_show(show)
      # Set year attributes
      show.data["year"] = get_show_year(show)
      show.data["year_page"] = get_show_year_page(show)

Severity: Minor
Found in _plugins/show.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Method has too many lines. [45/30]
Open

    def missing_majority(show)
      # We don't have crew_incomplete yet, so let's work it out.
      show_crew_count = show.data["crew"] ? show.data["crew"].length : 0
      amount_missing = 0 
      missing_fields = ''
Severity: Minor
Found in _plugins/show.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method generate_show has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def generate_show(show)
      # Set year attributes
      show.data["year"] = get_show_year(show)
      show.data["year_page"] = get_show_year_page(show)

Severity: Major
Found in _plugins/show.rb - About 2 hrs to fix

Cyclomatic complexity for missing_majority is too high. [12/6]
Open

    def missing_majority(show)
      # We don't have crew_incomplete yet, so let's work it out.
      show_crew_count = show.data["crew"] ? show.data["crew"].length : 0
      amount_missing = 0 
      missing_fields = ''
Severity: Minor
Found in _plugins/show.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

File show.rb has 259 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Jekyll
  class ShowDataGenerator < Jekyll::Generator
    priority :high

    # From years.rb
Severity: Minor
Found in _plugins/show.rb - About 2 hrs to fix

Method missing_majority has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def missing_majority(show)
      # We don't have crew_incomplete yet, so let's work it out.
      show_crew_count = show.data["crew"] ? show.data["crew"].length : 0
      amount_missing = 0 
      missing_fields = ''
Severity: Minor
Found in _plugins/show.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

Cyclomatic complexity for get_show_playwright is too high. [8/6]
Open

    def get_show_playwright(show)
      if show.data.key?("playwright") and not show.data["playwright"].nil?
        if show.data["playwright"] == "various"
          # Is various, special case
          ["various", nil, "Various Writers"]
Severity: Minor
Found in _plugins/show.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Method missing_majority has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def missing_majority(show)
      # We don't have crew_incomplete yet, so let's work it out.
      show_crew_count = show.data["crew"] ? show.data["crew"].length : 0
      amount_missing = 0 
      missing_fields = ''
Severity: Minor
Found in _plugins/show.rb - About 1 hr to fix

Method get_show_playwright has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def get_show_playwright(show)
      if show.data.key?("playwright") and not show.data["playwright"].nil?
        if show.data["playwright"] == "various"
          # Is various, special case
          ["various", nil, "Various Writers"]
Severity: Minor
Found in _plugins/show.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 get_show_asset_type has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def get_show_asset_type(show, key, image_only=true)
      show.data["assets"].select do |i|
        # Skip non-images if image_only
        if image_only and not i.key?("image") then next end

Severity: Minor
Found in _plugins/show.rb - About 35 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 get_show_display_image has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def get_show_display_image(show)
      # Assets required
      return nil unless show.data.key?("assets")

      # Find assets that fit the criteria for being a display image
Severity: Minor
Found in _plugins/show.rb - About 35 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

Avoid too many return statements within this method.
Open

        return programmes[0]
Severity: Major
Found in _plugins/show.rb - About 30 mins to fix

Avoid too many return statements within this method.
Open

        return nil
Severity: Major
Found in _plugins/show.rb - About 30 mins to fix

Useless assignment to variable - show_crew_count.
Open

      show_crew_count = show.data["crew"] ? show.data["crew"].length : 0
Severity: Minor
Found in _plugins/show.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

Literal """Send a person_list to the reverse index""" used in void context.
Open

      """Send a person_list to the reverse index"""
Severity: Minor
Found in _plugins/show.rb by rubocop

This cop checks for operators, variables and literals used in void context.

Example:

# bad

def some_method
  some_num * 10
  do_something
end

Example:

# bad

def some_method(some_var)
  some_var
  do_something
end

Example:

# good

def some_method
  do_something
  some_num * 10
end

Example:

# good

def some_method(some_var)
  do_something
  some_var
end

Literal """Returns a hash of shows by year""" used in void context.
Open

      """Returns a hash of shows by year"""
Severity: Minor
Found in _plugins/show.rb by rubocop

This cop checks for operators, variables and literals used in void context.

Example:

# bad

def some_method
  some_num * 10
  do_something
end

Example:

# bad

def some_method(some_var)
  some_var
  do_something
end

Example:

# good

def some_method
  do_something
  some_num * 10
end

Example:

# good

def some_method(some_var)
  do_something
  some_var
end

There are no issues that match your filters.

Category
Status