estiens/caterpillar_rails

View on GitHub

Showing 5 of 64 total issues

Class DoseInfo has 36 methods (exceeds 20 allowed). Consider refactoring.
Open

class DoseInfo < ApplicationRecord
  belongs_to :drug

  def info_string
    info_strings = [insufflation_dose_string, oral_dose_string, smoked_dose_string,
Severity: Minor
Found in app/models/dose_info.rb - About 4 hrs to fix

    Class Drug has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Drug < ApplicationRecord
      has_one :dose_info
    
      def self.find_with_aliases(name)
        name = name&.downcase
    Severity: Minor
    Found in app/models/drug.rb - About 2 hrs to fix

      Method test_results has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def test_results
          test_result_string = ''
          test_result_string += "Marquis test: #{marquis_test}. " if marquis_test
          test_result_string += "Mandelin test: #{mandelin_test}. " if mandelin_test
          test_result_string += "Mecke test: #{mecke_test}. " if mecke_test
      Severity: Minor
      Found in app/models/drug.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 create_substance_from_info has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def create_substance_from_info
            return false unless info_lookup
            @new_substance = Drug.find_by(name: @name)
            return 'skipped' unless @force || @new_substance.nil?
            @new_substance = Drug.find_or_create_by(name: @name)
      Severity: Minor
      Found in lib/tripsit.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 indefinite_article has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def indefinite_article
          first_word = to_s.split(/[- ]/).first
          if (first_word[AN_REQUIRING_PATTERNS] || first_word[UPCASE_AN_REQUIRING_PATTERNS]) &&
             !(first_word[A_REQUIRING_PATTERNS] || first_word[UPCASE_A_REQUIRING_PATTERNS])
            'an'
      Severity: Minor
      Found in lib/helpers/indefinite_article.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