Arie/serveme

View on GitHub

Showing 41 of 41 total issues

Class Server has 80 methods (exceeds 20 allowed). Consider refactoring.
Open

class Server < ActiveRecord::Base
  include ApplicationHelper

  has_many :group_servers
  has_many :groups, through: :group_servers
Severity: Major
Found in app/models/server.rb - About 1 day to fix

    Class Reservation has 57 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Reservation < ActiveRecord::Base
      belongs_to :user
      belongs_to :server
      belongs_to :server_config, optional: true
      belongs_to :whitelist, optional: true
    Severity: Major
    Found in app/models/reservation.rb - About 1 day to fix

      File server.rb has 395 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      class Server < ActiveRecord::Base
        include ApplicationHelper
      
        has_many :group_servers
        has_many :groups, through: :group_servers
      Severity: Minor
      Found in app/models/server.rb - About 5 hrs to fix

        Method right has 99 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.right
            %w[
              alba
              admirable
              adysky
        Severity: Major
        Found in app/services/friendly_password_generator.rb - About 3 hrs to fix

          Method sort_bucket_objects has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

            def sort_bucket_objects(objects, statistics, sort_by)
              sort_by_attribute = friendly_sort_name_to_attribute(sort_by)
              sort_by_object = if %i[map_name size].include?(sort_by_attribute)
                                 :self
                               else
          Severity: Minor
          Found in app/controllers/map_uploads_controller.rb - About 3 hrs 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 league_configs has 72 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.league_configs
              %w[
                etf2l
                etf2l_6v6
                etf2l_6v6_5cp
          Severity: Major
          Found in app/services/rcon_autocomplete.rb - About 2 hrs to fix

            Class ReservationsController has 23 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class ReservationsController < ApplicationController
              before_action :require_admin, only: %i[streaming]
              skip_before_action :redirect_if_country_banned, only: :played_in
              skip_before_action :authenticate_user!, only: %i[motd]
              skip_before_action :store_current_location, only: %i[extend_reservation destroy]
            Severity: Minor
            Found in app/controllers/reservations_controller.rb - About 2 hrs to fix

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

              class User < ActiveRecord::Base
                devise :omniauthable, :rememberable, :trackable
              
                has_many :reservations
                has_many :log_uploads, through: :reservations
              Severity: Minor
              Found in app/models/user.rb - About 2 hrs to fix

                Method commands_to_suggest has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def self.commands_to_suggest
                    [
                      { command: 'ban', description: 'Ban a player' },
                      { command: 'banid', description: 'Ban a player by ID' },
                      { command: 'banip', description: 'Ban an IP address' },
                Severity: Major
                Found in app/services/rcon_autocomplete.rb - About 2 hrs to fix

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

                  class LogWorker
                    include Sidekiq::Worker
                    sidekiq_options retry: 1
                  
                    attr_accessor :raw_line, :line, :message
                  Severity: Minor
                  Found in app/workers/log_worker.rb - About 2 hrs to fix

                    File rcon_autocomplete.rb has 259 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    class RconAutocomplete
                      attr_accessor :query, :reservation
                    
                      def initialize(reservation = nil)
                        @reservation = reservation
                    Severity: Minor
                    Found in app/services/rcon_autocomplete.rb - About 2 hrs to fix

                      Method status has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def status
                          Rails.cache.fetch "server_info_#{server.id}", expires_in: 1.minute do
                            out = {}
                            fetch_rcon_status.lines.each do |line|
                              case line
                      Severity: Minor
                      Found in app/models/server_info.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

                      Method start_reservation has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def start_reservation(reservation)
                          reservation.enable_mitigations if supports_mitigations?
                      
                          update_configuration(reservation)
                          if reservation.enable_plugins? || reservation.enable_demos_tf? || au_system?
                      Severity: Minor
                      Found in app/models/server.rb - About 1 hr to fix

                        Method sort_bucket_objects has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def sort_bucket_objects(objects, statistics, sort_by)
                            sort_by_attribute = friendly_sort_name_to_attribute(sort_by)
                            sort_by_object = if %i[map_name size].include?(sort_by_attribute)
                                               :self
                                             else
                        Severity: Minor
                        Found in app/controllers/map_uploads_controller.rb - About 1 hr to fix

                          Method status has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def status
                              return 'Ended' if past?
                          
                              status_messages = reservation_statuses.pluck(:status)
                              return 'Ended' if status_messages.include?('Finished zipping logs and demos')
                          Severity: Minor
                          Found in app/models/reservation.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

                          Method copy_from_server has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def copy_from_server(files, destination)
                              return if files.none?
                          
                              logger.debug "FTP GET, FILES: #{files} DESTINATION: #{destination}"
                              threads = []
                          Severity: Minor
                          Found in app/behaviour/ftp_access.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

                          Method start_reservation has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def start_reservation(reservation)
                              reservation.enable_mitigations if supports_mitigations?
                          
                              update_configuration(reservation)
                              if reservation.enable_plugins? || reservation.enable_demos_tf? || au_system?
                          Severity: Minor
                          Found in app/models/server.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

                          Method show has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def show
                              reservation_id = params[:id]&.split('-')&.[](1)&.to_i
                              respond_to do |format|
                                format.zip do
                                  reservation = find_reservation(reservation_id)
                          Severity: Minor
                          Found in app/controllers/uploads_controller.rb - About 55 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 update_reservation has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def update_reservation
                              respond_to do |format|
                                format.html do
                                  if reservation.update(reservation_params)
                                    if reservation.now?
                          Severity: Minor
                          Found in app/helpers/reservations_helper.rb - About 55 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 initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              def initialize(name, steam_id, connect_duration, ping, loss, state, ip)
                          Severity: Major
                          Found in app/services/rcon_status_parser.rb - About 50 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language