codeforamerica/ohana-api

View on GitHub

Showing 5 of 170 total issues

Function main has a Cognitive Complexity of 14 (exceeds 6 allowed). Consider refactoring.
Open

var main = (function () {
"use strict";

  var NUM_LEVELS = 2;

Severity: Minor
Found in app/assets/javascripts/admin/categories_form.js - 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 pages has a Cognitive Complexity of 10 (exceeds 6 allowed). Consider refactoring.
Open

  def pages(coll)
    pages = {}
    # current_page and total_pages are available via the kaminari gem
    unless coll.first_page?
      pages[:first] = 1
Severity: Minor
Found in app/controllers/concerns/pagination_headers.rb - About 55 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 regex_validate_each has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def regex_validate_each(regex, err_msg, record, attribute, value)
Severity: Minor
Found in app/validators/regex_validator.rb - About 35 mins to fix

    Method validate has a Cognitive Complexity of 8 (exceeds 6 allowed). Consider refactoring.
    Open

        def validate(value)
          @validators.each do |validator|
            next if value.nil? && validator.options[:allow_nil]
            next if value.blank? && validator.options[:allow_blank]
    
    
    Severity: Minor
    Found in app/validators/array_validator.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 split_date has a Cognitive Complexity of 7 (exceeds 6 allowed). Consider refactoring.
    Open

      def split_date(date)
        if date.include?('/')
          date.split('/').map(&:to_i)
        else
          date.tr(',', '').split.map.with_index do |e, i|
    Severity: Minor
    Found in app/validators/date_validator.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