hpi-swt2/workshop-portal

View on GitHub

Showing 7 of 494 total issues

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

  def compare_participants_by_agreement(participant1, participant2)
    if participant1.requires_agreement_letter_for_event?(self)
      if participant2.requires_agreement_letter_for_event?(self)
        return participant1.name <=> participant2.name
      end
Severity: Minor
Found in app/models/event.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 send_generic_email has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def self.send_generic_email(hide_recipients, recipients, reply_to, subject, content)
Severity: Minor
Found in app/services/mailer.rb - About 35 mins to fix

    Method initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def initialize(user)
        # Define abilities for the passed in user here. For example:
        #
        #   user ||= User.new # guest user (not logged in)
        #   if user.admin?
    Severity: Minor
    Found in app/models/ability.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 participant1.name <=> participant2.name
    Severity: Major
    Found in app/models/event.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

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

        Avoid too many return statements within this method.
        Open

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

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

            def older_than_required_age_at_start_date_of_event?(given_event, age)
              return false unless self.profile
              event_start = given_event.start_date
              event_start_is_before_birthday = event_start.month > self.profile.birth_date.month || (event_start.month == self.profile.birth_date.month && event_start.day >= self.profile.birth_date.day)
              age_at_event_start = event_start.year - self.profile.birth_date.year - (event_start_is_before_birthday ? 0 : 1)
          Severity: Minor
          Found in app/models/user.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