steventwheeler/clli

View on GitHub

Showing 4 of 40 total issues

Class CLLI has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

class CLLI
  ##
  # This module provides the various patterns used for parsing +CLLI+ strings.
  module Pattern
    ##
Severity: Minor
Found in lib/clli/pattern.rb - About 2 hrs to fix

    Method state_name has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def state_name(region_code)
            state_code = iso_state(region_code)
            return unless state_code
            country_code = iso_country(region_code)
            return unless country_code
    Severity: Minor
    Found in lib/clli/iso3166.rb - About 45 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 validate_attribute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def validate_attribute(error_prefix, value, length, regexp, **options)
            fail "#{error_prefix} cannot be nil." if value.nil?
            fail "#{error_prefix} cannot be empty." if value.to_s.empty?
            fail "#{error_prefix} must be #{length} #{pluralize(length, 'character')} long." unless value.to_s.size == length
            return unless options[:strict]
    Severity: Minor
    Found in lib/clli/validations.rb - About 45 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 validate_attribute has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def validate_attribute(error_prefix, value, length, regexp, **options)
    Severity: Minor
    Found in lib/clli/validations.rb - About 35 mins to fix
      Severity
      Category
      Status
      Source
      Language