Derek-R-S/Light-Reflective-Mirror

View on GitHub

Showing 34 of 34 total issues

Method HandleMessage has 77 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public void HandleMessage(int clientId, ArraySegment<byte> segmentData, int channel)
        {
            try
            {
                var data = segmentData.Array;

    Method MainAsync has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            public async Task MainAsync()
            {
                WriteTitle();
                instance = this;
                _startupTime = DateTime.Now;
    Severity: Major
    Found in ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Program/Program.cs - About 2 hrs to fix

      Method HandleMessage has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
      Open

              public void HandleMessage(int clientId, ArraySegment<byte> segmentData, int channel)
              {
                  try
                  {
                      var data = segmentData.Array;

      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 JoinRoom has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              private void JoinRoom(int clientId, string serverId, bool canDirectConnect, string localIP)
              {
                  LeaveRoom(clientId);
      
                  if (_cachedRooms.ContainsKey(serverId))

        Method ConfigureTransport has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                private void ConfigureTransport(Assembly asm)
                {
                    var transportClass = asm.GetType(conf.TransportClass);
                    WriteLogMessage("OK", ConsoleColor.Green);
        
        

          Method LeaveRoom has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  private void LeaveRoom(int clientId, int requiredHostId = -1)
                  {
                      for (int i = 0; i < rooms.Count; i++)
                      {
                          // if host left

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                    [RestRoute("Options", "/api/masterlist/")]
                    public async Task GetMasterServerListOptions(IHttpContext context)
                    {
                        var originHeaders = context.Request.Headers["Access-Control-Request-Headers"];
            
            
            LoadBalancerProject-DONT-IMPORT-INTO-UNITY/LRM_LoadBalancer/Endpoint/Endpoint.cs on lines 149..159
            ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Endpoint.cs on lines 82..92

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 133.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                    [RestRoute("Options", "/api/compressed/servers")]
                    public async Task ServerListCompressedOptions(IHttpContext context)
                    {
                        var originHeaders = context.Request.Headers["Access-Control-Request-Headers"];
            
            
            Severity: Major
            Found in ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Endpoint.cs and 2 other locations - About 1 hr to fix
            LoadBalancerProject-DONT-IMPORT-INTO-UNITY/LRM_LoadBalancer/Endpoint/Endpoint.cs on lines 149..159
            LoadBalancerProject-DONT-IMPORT-INTO-UNITY/LRM_LoadBalancer/Endpoint/Endpoint.cs on lines 181..191

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 133.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                    [RestRoute("Options", "/api/join/")]
                    public async Task JoinRelayOptions(IHttpContext context)
                    {
                        var originHeaders = context.Request.Headers["Access-Control-Request-Headers"];
            
            
            LoadBalancerProject-DONT-IMPORT-INTO-UNITY/LRM_LoadBalancer/Endpoint/Endpoint.cs on lines 181..191
            ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Endpoint.cs on lines 82..92

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 133.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

                    private async Task HeartbeatLoop()
                    {
                        // default heartbeat data
                        byte[] heartbeat = new byte[] { 200 };
            
            
            Severity: Minor
            Found in ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Program/Program.cs - About 1 hr to fix

              Method RunNATPunchLoop has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      void RunNATPunchLoop()
                      {
                          WriteLogMessage("OK\n", ConsoleColor.Green);
                          IPEndPoint remoteEndpoint = new(IPAddress.Any, conf.NATPunchtroughPort);
              
              

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

                        private void CreateRoom(int clientId, int maxPlayers, string serverName, bool isPublic, string serverData, bool useDirectConnect, string hostLocalIP, bool useNatPunch, int port)
                        {
                            LeaveRoom(clientId);
                            Program.instance.NATConnections.TryGetValue(clientId, out IPEndPoint hostIP);
                
                

                  Method CreateRoom has 9 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          private void CreateRoom(int clientId, int maxPlayers, string serverName, bool isPublic, string serverData, bool useDirectConnect, string hostLocalIP, bool useNatPunch, int port)

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

                            [RestRoute("Get", "/api/join/")]
                            public async Task JoinRelay(IHttpContext context)
                            {
                                // need to copy over in order to avoid
                                // collection being modified while iterating.

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

                              [RestRoute("Get", "/api/auth")]
                              public async Task ReceiveAuthKey(IHttpContext context)
                              {
                                  var req = context.Request;
                                  string receivedAuthKey = req.Headers["Authorization"];

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

                                public bool Start(ushort port = 7070)
                                {
                                    try
                                    {
                                        // Initialize the region variables

                          Method WriteTitle has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                  void WriteTitle()
                                  {
                                      string t = @"  
                            _        _____    __  __                                                
                           | |      |  __ \  |  \/  |                                               

                            Method Start has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                    public bool Start(ushort port = 8080)
                                    {
                                        try
                                        {
                                            var config = new ConfigurationBuilder()
                            Severity: Minor
                            Found in ServerProject-DONT-IMPORT-INTO-UNITY/LRM/Endpoint.cs - About 1 hr to fix

                              Method MainAsync has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                      public async Task MainAsync()
                                      {
                                          WriteTitle();
                              
                                          instance = this;

                                Consider simplifying this complex logical expression.
                                Open

                                            if (receivedAuthKey != null && region != null && int.TryParse(region, out int regionId) &&
                                                address != null && endpointPort != null && gamePort != null && receivedAuthKey == Program.conf.AuthKey)
                                            {
                                                Logger.WriteLogMessage($"Server accepted: {address}:{gamePort}");
                                
                                
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language