SpeciesFileGroup/taxonworks

View on GitHub
app/models/identifier/global/lccn.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method using_iccn_class has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

  def using_iccn_class
    unless identifier.nil?
      lccn = identifier

      # '200112345', '2010549727', '2003064850', '|a  2003064850', '88156495', '68-004897', '2001-459440'
Severity: Minor
Found in app/models/identifier/global/lccn.rb - About 5 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

Method has too many lines. [38/25]
Open

  def using_iccn_class
    unless identifier.nil?
      lccn = identifier

      # '200112345', '2010549727', '2003064850', '|a  2003064850', '88156495', '68-004897', '2001-459440'

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

  def using_iccn_class
    unless identifier.nil?
      lccn = identifier

      # '200112345', '2010549727', '2003064850', '|a  2003064850', '88156495', '68-004897', '2001-459440'
Severity: Minor
Found in app/models/identifier/global/lccn.rb - About 1 hr to fix

    Avoid more than 3 levels of block nesting.
    Open

                if serial < 6000
                  century = '18'
                end

    This cop checks for excessive nesting of conditional and looping constructs.

    You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

    The maximum level of nesting allowed is configurable.

    Avoid more than 3 levels of block nesting.
    Open

                if serial >= 8000
                  century = '20'
                end

    This cop checks for excessive nesting of conditional and looping constructs.

    You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

    The maximum level of nesting allowed is configurable.

    Avoid more than 3 levels of block nesting.
    Open

                if serial < 3000
                  century = '18'
                end

    This cop checks for excessive nesting of conditional and looping constructs.

    You can configure if blocks are considered using the CountBlocks option. When set to false (the default) blocks are not counted towards the nesting level. Set to true to count blocks as well.

    The maximum level of nesting allowed is configurable.

    Do not use Time.now without zone. Use one of Time.zone.now, Time.current, Time.now.in_time_zone, Time.now.utc, Time.now.getlocal, Time.now.xmlschema, Time.now.iso8601, Time.now.jisx0301, Time.now.rfc3339, Time.now.httpdate, Time.now.to_i, Time.now.to_f instead.
    Open

            if (year > Time.now.year) or (year < 2001)

    This cop checks for the use of Time methods without zone.

    Built on top of Ruby on Rails style guide (https://github.com/rubocop-hq/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/

    Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.

    When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.

    Example: EnforcedStyle: strict

    # `strict` means that `Time` should be used with `zone`.
    
    # bad
    Time.now
    Time.parse('2015-03-02 19:05:37')
    
    # bad
    Time.current
    Time.at(timestamp).in_time_zone
    
    # good
    Time.zone.now
    Time.zone.parse('2015-03-02 19:05:37')

    Example: EnforcedStyle: flexible (default)

    # `flexible` allows usage of `in_time_zone` instead of `zone`.
    
    # bad
    Time.now
    Time.parse('2015-03-02 19:05:37')
    
    # good
    Time.zone.now
    Time.zone.parse('2015-03-02 19:05:37')
    
    # good
    Time.current
    Time.at(timestamp).in_time_zone

    There are no issues that match your filters.

    Category
    Status