pupilfirst/pupilfirst

View on GitHub

Showing 124 of 226 total issues

Avoid too many return statements within this method.
Open

    return false if organisation.blank?
Severity: Major
Found in app/policies/timeline_event_file_policy.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

          return false
    Severity: Major
    Found in app/services/discord/add_member_service.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return true if course.faculty.exists?(user: current_user)
      Severity: Major
      Found in app/graphql/mutations/create_reaction.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

            return true if course.faculty.exists?(user: current_user)
        Severity: Major
        Found in app/queries/discussion_submissions_resolver.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

              return false if organisation.blank?
          Severity: Major
          Found in app/policies/timeline_event_policy.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                  return true if course.faculty.exists?(user: current_user)
            Severity: Major
            Found in app/graphql/mutations/create_moderation_report.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    return true if course.faculty.exists?(user: current_user)
              Severity: Major
              Found in app/graphql/mutations/create_submission_comment.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                    return true if current_school_admin.present?
                Severity: Major
                Found in app/policies/timeline_event_file_policy.rb - About 30 mins to fix

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

                      def token
                        user =
                          Users::AuthenticationService.new(
                            current_school,
                            params[:token]
                  Severity: Minor
                  Found in app/controllers/users/sessions_controller.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 stringify_ids_in_array has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def stringify_ids_in_array(key, array)
                      if key.ends_with?('_ids')
                        array.map(&:to_s)
                      else
                        array.map do |element|
                  Severity: Minor
                  Found in lib/stringify_ids.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 download? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def download?
                      return false if user.blank?
                  
                      timeline_event = record.timeline_event
                  
                  
                  Severity: Minor
                  Found in app/policies/timeline_event_file_policy.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 courses has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def courses
                        if current_user.blank?
                          current_school
                            .courses.with_attached_thumbnail
                            .live
                  Severity: Minor
                  Found in app/presenters/layouts/app_router_presenter.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 mark_as_read? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def mark_as_read?
                      return false if user.blank?
                  
                      # Has access to school
                      return false unless course&.school == @current_school && student.present?
                  Severity: Minor
                  Found in app/policies/target_policy.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 curriculum? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def curriculum?
                      return true if record.public_preview?
                  
                      if current_school_admin.present? ||
                           user.course_authors.where(course: record).present?
                  Severity: Minor
                  Found in app/policies/course_policy.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 status has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def status
                      if passed_at.blank?
                        evaluated_at.present? ? :failed : :pending
                      else
                        evaluated_at.present? ? :passed : :marked_as_complete
                  Severity: Minor
                  Found in app/models/timeline_event.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 connect? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def connect?
                      # Cannot connect if connect link is blank.
                      return false if record.connect_link.blank?
                  
                      if user&.students.present?
                  Severity: Minor
                  Found in app/policies/faculty_policy.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 merge_student_profiles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def merge_student_profiles
                        return if @old_user.students.blank?
                  
                        Rails.logger.info("Merging student profiles...")
                  
                  
                  Severity: Minor
                  Found in app/services/users/merge_accounts_service.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 execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def execute
                      variables = ensure_hash(params[:variables])
                      query = params[:query]
                      operation_name = params[:operationName]
                  
                  
                  Severity: Minor
                  Found in app/controllers/graphql_controller.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 merge_coach_profiles has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def merge_coach_profiles
                        old_user_coach = @old_user.faculty
                  
                        return if @old_user.faculty.blank?
                  
                  
                  Severity: Minor
                  Found in app/services/users/merge_accounts_service.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 clone has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def clone(new_name, school)
                        Course.transaction do
                          Course
                            .create!(
                              name: new_name,
                  Severity: Minor
                  Found in app/services/courses/clone_service.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