estiens/caterpillar_rails

View on GitHub
app/models/drug.rb

Summary

Maintainability
A
3 hrs
Test Coverage

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

    Specify a :dependent option.
    Open

      has_one :dose_info
    Severity: Minor
    Found in app/models/drug.rb by rubocop

    This cop looks for has_many or has_one associations that don't specify a :dependent option. It doesn't register an offense if :through option was specified.

    Example:

    # bad
    class User < ActiveRecord::Base
      has_many :comments
      has_one :avatar
    end
    
    # good
    class User < ActiveRecord::Base
      has_many :comments, dependent: :restrict_with_exception
      has_one :avatar, dependent: :destroy
      has_many :patients, through: :appointments
    end

    Re-enable Metrics/CyclomaticComplexity cop with # rubocop:enable after disabling it.
    Open

      # rubocop:disable Metrics/CyclomaticComplexity
    Severity: Minor
    Found in app/models/drug.rb by rubocop

    Re-enable Metrics/PerceivedComplexity cop with # rubocop:enable after disabling it.
    Open

      # rubocop:disable Metrics/PerceivedComplexity
    Severity: Minor
    Found in app/models/drug.rb by rubocop

    Re-enable Metrics/MethodLength cop with # rubocop:enable after disabling it.
    Open

      # rubocop:disable Metrics/MethodLength
    Severity: Minor
    Found in app/models/drug.rb by rubocop

    Re-enable Metrics/AbcSize cop with # rubocop:enable after disabling it.
    Open

      # rubocop:disable Metrics/AbcSize
    Severity: Minor
    Found in app/models/drug.rb by rubocop

    There are no issues that match your filters.

    Category
    Status