Showing 20 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;
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;
- 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 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
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 };
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()
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}");
Method AddServer
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public async Task AddServer(string serverIP, ushort port, ushort endpointPort, string publicIP, int regionId)
Method MainAsync
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
public async Task MainAsync()
{
WriteTitle();
instance = this;
_startupTime = DateTime.Now;
- 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 HeartbeatLoop
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
private async Task HeartbeatLoop()
{
// default heartbeat data
byte[] heartbeat = new byte[] { 200 };
- 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"