ozfortress/citadel

View on GitHub

Showing 18 of 34 total issues

Class Match has 30 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Match < ApplicationRecord
    include MarkdownRenderCaching

    belongs_to :home_team, class_name: 'Roster'
    belongs_to :away_team, class_name: 'Roster', optional: true
Severity: Minor
Found in app/models/league/match.rb - About 3 hrs to fix

    Class MatchesController has 28 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class MatchesController < ApplicationController
        include MatchesCommon
    
        before_action only: [:index, :new, :create, :generate, :create_round] do
          @league = League.find(params[:league_id])
    Severity: Minor
    Found in app/controllers/leagues/matches_controller.rb - About 3 hrs to fix

      Class RostersController has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class RostersController < ApplicationController
          include RosterPermissions
          include TeamPermissions
      
          before_action only: [:index, :new, :create] do
      Severity: Minor
      Found in app/controllers/leagues/rosters_controller.rb - About 2 hrs to fix

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

            class TransferRequest < ApplicationRecord
              belongs_to :roster
              belongs_to :leaving_roster, class_name: 'Roster', optional: true
        
              belongs_to :user
        Severity: Minor
        Found in app/models/league/roster/transfer_request.rb - About 2 hrs to fix

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

          class UsersController < ApplicationController
            include UsersPermissions
          
            before_action only: [:show, :edit, :update, :request_name_change] do
              @user = User.find(params[:id])
          Severity: Minor
          Found in app/controllers/users_controller.rb - About 2 hrs to fix

            Method update_rosters has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def update_rosters(league, rosters, roster_results, opponents_map)
                    points_map = Hash.new { |h, k| h[k] = [] }
            
                    # Update scores from gathered stats
                    rosters.each do |roster|
            Severity: Minor
            Found in app/services/leagues/rosters/score_updating_service.rb - About 1 hr to fix

              Function render has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function render(containerj, canvas) {
                      // Use twice the scale for better resolution on high dpi displays
                      var container = containerj[0];
                      var width = container.scrollWidth;
                      var height = container.scrollHeight;
              Severity: Minor
              Found in app/assets/javascripts/brackets.js - About 1 hr to fix

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

                      def on_roster_check
                        return unless user.present? && roster.present?
                
                        if roster.on_roster?(user)
                          errors.add(:user_id, 'Is already on the roster') if is_joining?
                Severity: Minor
                Found in app/models/league/roster/transfer_request.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 call has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                      def call(user, thread, params, post, post_params)
                Severity: Minor
                Found in app/services/forums/threads/editing_service.rb - About 35 mins to fix

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

                    def require_permission
                      if subject?
                        redirect_back unless user_can_edit_permissions?
                      else
                        redirect_back unless current_user.can?(:edit, :permissions) || current_user.can?(@action, admin_subject)
                  Severity: Minor
                  Found in app/controllers/permissions_controller.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

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

                        def transform_data(data)
                          data.select! { |key, _| %w[type availability].include?(key.to_s) }
                  
                          return unless data['type'] == 'weekly'
                  
                  
                  Severity: Minor
                  Found in app/models/league/schedulers/weekly.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

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

                      def set_defaults
                        return unless topic
                  
                        self.pinned = false if pinned.nil?
                  
                  
                  Severity: Minor
                  Found in app/models/forums/thread.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 within_roster_size_limits has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def within_roster_size_limits
                        return if league.blank?
                  
                        unless league.valid_roster_size?(players.size)
                          errors.add(:players, "Must have at least #{league.min_players} players" +
                  Severity: Minor
                  Found in app/models/league/roster.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 notify_users has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def notify_users(users, topic, thread)
                          message = "#{thread.created_by.name} created #{thread.title} in #{topic.name}"
                          url = forums_thread_path(thread)
                  
                          users.each do |user|
                  Severity: Minor
                  Found in app/services/forums/threads/creation_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 set_defaults has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def set_defaults
                      self.status ||= :private
                      self.signuppable ||= true
                      self.roster_locked = false if roster_locked.blank?
                  
                  
                  Severity: Minor
                  Found in app/models/league.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 set_defaults has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def set_defaults
                        [:pinned, :isolated, :default_hidden].each do |attribute|
                          self[attribute] = false if self[attribute].nil?
                        end
                  
                  
                  Severity: Minor
                  Found in app/models/forums/topic.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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def create
                        @ban = @model.new(ban_params.merge(user: @user))
                  
                        if @ban.save
                          redirect_to user_bans_path(@user)
                  Severity: Minor
                  Found in app/controllers/users/bans_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 map_and_pick_present has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def map_and_pick_present
                          if map
                            errors.add(:picked_by, 'Must be present') unless picked_by
                          elsif picked_by && !deferred?
                            errors.add(:map, 'Must be present')
                  Severity: Minor
                  Found in app/models/league/match/pick_ban.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