codeRIT/hackathon_manager

View on GitHub
app/controllers/manage/dashboard_controller.rb

Summary

Maintainability
A
1 hr
Test Coverage

Cyclomatic complexity for activity_chart_data is too high. [11/10]
Open

  def activity_chart_data(types, group_type, range, where_filter = nil)
    chart_data = []
    types.each do |type|
      case type
      when "Applications"

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 schools_applied_data has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def schools_applied_data
    counted_schools = {
      "pending" => {},
      "denied" => {},
      "rsvp_denied" => {},
Severity: Minor
Found in app/controllers/manage/dashboard_controller.rb - About 1 hr to fix

    Avoid comma after the last item of an array.
    Open

          { name: "Riding bus", data: schools_riding },

    This cop checks for trailing comma in array literals.

    Example: EnforcedStyleForMultiline: consistent_comma

    # bad
    a = [1, 2,]
    
    # good
    a = [
      1, 2,
      3,
    ]
    
    # good
    a = [
      1,
      2,
    ]

    Example: EnforcedStyleForMultiline: comma

    # bad
    a = [1, 2,]
    
    # good
    a = [
      1,
      2,
    ]

    Example: EnforcedStyleForMultiline: no_comma (default)

    # bad
    a = [1, 2,]
    
    # good
    a = [
      1,
      2
    ]

    Use School.where("questionnaire_count >= 5").count.positive? instead of School.where("questionnaire_count >= 5").count > 0.
    Open

        if School.where("questionnaire_count >= 5").count > 0

    This cop checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. The cop can also be configured to do the reverse.

    The cop disregards #nonzero? as it its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

    The cop ignores comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Integer polymorphic.

    Example: EnforcedStyle: predicate (default)

    # bad
    
    foo == 0
    0 > foo
    bar.baz > 0
    
    # good
    
    foo.zero?
    foo.negative?
    bar.baz.positive?

    Example: EnforcedStyle: comparison

    # bad
    
    foo.zero?
    foo.negative?
    bar.baz.positive?
    
    # good
    
    foo == 0
    0 > foo
    bar.baz > 0

    Avoid comma after the last item of an array.
    Open

          { name: "Pending", data: counted_schools["pending"] },

    This cop checks for trailing comma in array literals.

    Example: EnforcedStyleForMultiline: consistent_comma

    # bad
    a = [1, 2,]
    
    # good
    a = [
      1, 2,
      3,
    ]
    
    # good
    a = [
      1,
      2,
    ]

    Example: EnforcedStyleForMultiline: comma

    # bad
    a = [1, 2,]
    
    # good
    a = [
      1,
      2,
    ]

    Example: EnforcedStyleForMultiline: no_comma (default)

    # bad
    a = [1, 2,]
    
    # good
    a = [
      1,
      2
    ]

    There are no issues that match your filters.

    Category
    Status