openaustralia/atdis

View on GitHub

Showing 11 of 11 total issues

Class Model has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Model
    include ActiveModel::Validations
    include Validators
    include ActiveModel::AttributeMethods
    include TypeCastAttributes
Severity: Minor
Found in lib/atdis/model.rb - About 2 hrs to fix

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

        def self.cast(value, type, timezone)
          # If it's already the correct type (or nil) then we don't need to do anything
          if value.nil? || value.is_a?(type)
            value
          # Special handling for arrays. When we typecast arrays we actually
    Severity: Minor
    Found in lib/atdis/model.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 json_errors_local has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def json_errors_local
          r = []
          # First show special json error
          errors.attribute_names.each do |attribute|
            r << [nil, errors[:json]] unless errors[:json].empty?
    Severity: Minor
    Found in lib/atdis/model.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 count_is_consistent has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def count_is_consistent
            return if count.nil?
    
            if response.respond_to?(:count)
              if count != response.count
    Severity: Minor
    Found in lib/atdis/models/page.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 split has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.split(full_url)
          uri = URI.parse(full_url)
          url = if (uri.scheme == "http" && uri.port == 80) ||
                   (uri.scheme == "https" && uri.port == 443)
                  "#{uri.scheme}://#{uri.host}#{uri.path}"
    Severity: Minor
    Found in lib/atdis/separated_url.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 applications_url has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def applications_url(options = {})
          invalid_options = options.keys - VALID_OPTIONS
    
          raise "Unexpected options used: #{invalid_options.join(',')}" unless invalid_options.empty?
    
    
    Severity: Minor
    Found in lib/atdis/feed.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 json_errors_in_children has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def json_errors_in_children
          r = []
          attributes.each do |attribute_as_string, value|
            attribute = attribute_as_string.to_sym
            if value.respond_to?(:json_errors)
    Severity: Minor
    Found in lib/atdis/model.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 validate_each has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def validate_each(record, attribute, value)
            if value && !value.is_a?(Array)
              message = "should be an array"
              message = ErrorMessage[message, options[:spec_section]] if options[:spec_section]
              record.errors.add(attribute, message)
    Severity: Minor
    Found in lib/atdis/validators.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 partition_by_used has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.partition_by_used(data)
          used = {}
          unused = {}
          if data.respond_to?(:each)
            data.each do |key, value|
    Severity: Minor
    Found in lib/atdis/model.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

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

          def previous_is_consistent
            if previous && current && previous != current - 1
              errors.add(
                :previous,
                ErrorMessage["should be one less than current page number or null if first page", "6.4"]
    Severity: Minor
    Found in lib/atdis/models/pagination.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

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

        def self.options_from_url(url)
          u = URI.parse(url)
          options = query_to_options(u.query)
          %i[lodgement_date_start lodgement_date_end last_modified_date_start
             last_modified_date_end].each do |k|
    Severity: Minor
    Found in lib/atdis/feed.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