MiraitSystems/enju_trunk

View on GitHub
app/models/system_configuration.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method get has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def self.get(keyname)
    value = typename = nil

    s = Rails.cache.read("#{Prefix_Key}#{keyname}")
    if s
Severity: Minor
Found in app/models/system_configuration.rb - About 2 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 get has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.get(keyname)
    value = typename = nil

    s = Rails.cache.read("#{Prefix_Key}#{keyname}")
    if s
Severity: Minor
Found in app/models/system_configuration.rb - About 1 hr to fix

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

      def value_by_typename_is_valid
        case typename
        when "Text"
        when "String"
        when "Boolean"
    Severity: Minor
    Found in app/models/system_configuration.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 check_length has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def check_length
        case keyname
        when 'checkouts_print.message'
          if v.length > 152
            errors[:base] = I18n.t('system_configuration.error.over_checkouts_print_message', :num => 76)
    Severity: Minor
    Found in app/models/system_configuration.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

    Avoid too many return statements within this method.
    Open

          return v
    Severity: Major
    Found in app/models/system_configuration.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return value.to_i
      Severity: Major
      Found in app/models/system_configuration.rb - About 30 mins to fix

        There are no issues that match your filters.

        Category
        Status