CORE-POS/IS4C

View on GitHub
pos/is4c-nf/scale-drivers/drivers/NewMagellan/WebSocketServer.cs

Summary

Maintainability
D
2 days
Test Coverage

File WebSocketServer.cs has 407 lines of code (exceeds 250 allowed). Consider refactoring.
Open

using System;
using System.Net;
using System.Net.Sockets;
using System.Collections.Generic;
using System.Threading;
Severity: Minor
Found in pos/is4c-nf/scale-drivers/drivers/NewMagellan/WebSocketServer.cs - About 5 hrs to fix

    Method ConnectClient has 90 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            private void ConnectClient(IAsyncResult state)
            {
                TcpClient client;
                try {
                    TcpListener server = (TcpListener)state.AsyncState;
    Severity: Major
    Found in pos/is4c-nf/scale-drivers/drivers/NewMagellan/WebSocketServer.cs - About 3 hrs to fix

      Method ClientDataCallback has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
      Open

              private void ClientDataCallback(IAsyncResult state)
              {
                  try {
                      WsCallbackState cs = (WsCallbackState)state.AsyncState;
                      NetworkStream stream = cs.client.GetStream();
      Severity: Minor
      Found in pos/is4c-nf/scale-drivers/drivers/NewMagellan/WebSocketServer.cs - About 2 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 MessageToFrames has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              private byte[] MessageToFrames(string msg)
              {
                  byte[] payload = System.Text.Encoding.UTF8.GetBytes(msg);
                  byte[] resp;
                  if (payload.Length <= 125) {
      Severity: Major
      Found in pos/is4c-nf/scale-drivers/drivers/NewMagellan/WebSocketServer.cs - About 2 hrs to fix

        Method FramesToMessage has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                private WsDataFrame FramesToMessage(byte[] frames)
                {
                    if (frames.Length < 2) {
                        throw new WsProtocolException("Invalid frame: too short (header)");
                    }
        Severity: Major
        Found in pos/is4c-nf/scale-drivers/drivers/NewMagellan/WebSocketServer.cs - About 2 hrs to fix

          Method ConnectClient has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
          Open

                  private void ConnectClient(IAsyncResult state)
                  {
                      TcpClient client;
                      try {
                          TcpListener server = (TcpListener)state.AsyncState;
          Severity: Minor
          Found in pos/is4c-nf/scale-drivers/drivers/NewMagellan/WebSocketServer.cs - About 2 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 ClientDataCallback has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  private void ClientDataCallback(IAsyncResult state)
                  {
                      try {
                          WsCallbackState cs = (WsCallbackState)state.AsyncState;
                          NetworkStream stream = cs.client.GetStream();
          Severity: Minor
          Found in pos/is4c-nf/scale-drivers/drivers/NewMagellan/WebSocketServer.cs - About 1 hr to fix

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

                    public void Push(string msg)
                    {
                        _msg_queue.Enqueue(msg);
            
                        NetworkStream s = null;
            Severity: Minor
            Found in pos/is4c-nf/scale-drivers/drivers/NewMagellan/WebSocketServer.cs - About 1 hr to fix

              There are no issues that match your filters.

              Category
              Status