mumuki/mumuki-domain

View on GitHub

Showing 13 of 19 total issues

Class User has 66 methods (exceeds 20 allowed). Consider refactoring.
Open

class User < ApplicationRecord
  include Mumuki::Domain::Syncable
  include WithProfile,
          WithUserNavigation,
          WithReminders,
Severity: Major
Found in app/models/user.rb - About 1 day to fix

    Class Exercise has 42 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Exercise < ApplicationRecord
      RANDOMIZED_FIELDS = [:default_content, :description, :extra, :hint, :test, :expectations, :custom_expectations]
      BASIC_RESOURCE_FIELDS = %i(
        name layout editor corollary teacher_info manual_evaluation locale
        choices assistance_rules randomizations tag_list extra_visible goal
    Severity: Minor
    Found in app/models/exercise.rb - About 5 hrs to fix

      Class Assignment has 39 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class Assignment < Progress
        include Contextualization
        include WithMessages
        include Gamified
      
      
      Severity: Minor
      Found in app/models/assignment.rb - About 5 hrs to fix

        Class Organization has 37 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class Organization < ApplicationRecord
          include Mumuki::Domain::Syncable
          include Mumuki::Domain::Helpers::Organization
          include Mumuki::Domain::Area
        
        
        Severity: Minor
        Found in app/models/organization.rb - About 4 hrs to fix

          Class IncognitoClass has 35 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class IncognitoClass
          
              def incognito?
                true
              end
          Severity: Minor
          Found in lib/mumuki/domain/incognito.rb - About 4 hrs to fix

            Class Exam has 34 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class Exam < ApplicationRecord
            
              include GuideContainer
              include FriendlyName
              include TerminalNavigation
            Severity: Minor
            Found in app/models/exam.rb - About 4 hrs to fix

              Class Discussion has 32 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class Discussion < ApplicationRecord
                include WithDiscussionStatus, WithScopedQueries, Contextualization, WithResponsibleModerator
              
                belongs_to :item, polymorphic: true
                has_many :messages, -> { order(:created_at) }, dependent: :destroy
              Severity: Minor
              Found in app/models/discussion.rb - About 4 hrs to fix

                Class ApplicationRecord has 22 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class ApplicationRecord < ActiveRecord::Base
                  self.abstract_class = true
                
                  include WithPgLock
                
                
                Severity: Minor
                Found in app/models/application_record.rb - About 2 hrs to fix

                  Class ExamRegistration has 22 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  class ExamRegistration < ApplicationRecord
                    include WithTimedEnablement
                    include TerminalNavigation
                  
                    belongs_to :organization
                  Severity: Minor
                  Found in app/models/exam_registration.rb - About 2 hrs to fix

                    Method fields_schema has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def self.fields_schema
                        [
                          {name: :id, kind: :special},
                          {name: :name, kind: :special},
                          {name: :locale, kind: :metadata},
                    Severity: Minor
                    Found in lib/mumuki/domain/store/github/exercise_schema.rb - About 1 hr to fix

                      Method call has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            def call
                              {
                                name:                         @info['name'],
                                comment_type:                 @info['comment_type'],
                                runner_url:                   @runner_url,
                      Severity: Minor
                      Found in lib/mumuki/domain/store/thesaurus.rb - About 1 hr to fix

                        Method to_resource_h has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def to_resource_h
                            excluded_fields = %i(created_at exercise_id id organization_id parent_id solution submission_id
                                                 submission_status submitted_at submitter_id top_submission_status updated_at misplaced)
                        
                            as_json(except: excluded_fields,
                        Severity: Minor
                        Found in app/models/assignment.rb - About 1 hr to fix

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

                            def validate_accessible_for!(user)
                              if user.present?
                                raise Mumuki::Domain::ForbiddenError unless authorized?(user)
                                raise Mumuki::Domain::GoneError unless enabled_for?(user)
                              else
                          Severity: Minor
                          Found in app/models/exam.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

                          Severity
                          Category
                          Status
                          Source
                          Language