pos/is4c-nf/scale-drivers/drivers/NewMagellan/WebSocketServer.cs
File WebSocketServer.cs
has 407 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
using System;
using System.Net;
using System.Net.Sockets;
using System.Collections.Generic;
using System.Threading;
Method ConnectClient
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private void ConnectClient(IAsyncResult state)
{
TcpClient client;
try {
TcpListener server = (TcpListener)state.AsyncState;
Method ClientDataCallback
has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring. Open
Open
private void ClientDataCallback(IAsyncResult state)
{
try {
WsCallbackState cs = (WsCallbackState)state.AsyncState;
NetworkStream stream = cs.client.GetStream();
- Read upRead up
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
Open
private byte[] MessageToFrames(string msg)
{
byte[] payload = System.Text.Encoding.UTF8.GetBytes(msg);
byte[] resp;
if (payload.Length <= 125) {
Method FramesToMessage
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private WsDataFrame FramesToMessage(byte[] frames)
{
if (frames.Length < 2) {
throw new WsProtocolException("Invalid frame: too short (header)");
}
Method ConnectClient
has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring. Open
Open
private void ConnectClient(IAsyncResult state)
{
TcpClient client;
try {
TcpListener server = (TcpListener)state.AsyncState;
- Read upRead up
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
Open
private void ClientDataCallback(IAsyncResult state)
{
try {
WsCallbackState cs = (WsCallbackState)state.AsyncState;
NetworkStream stream = cs.client.GetStream();
Method Push
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public void Push(string msg)
{
_msg_queue.Enqueue(msg);
NetworkStream s = null;