Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aditydha committed Apr 8, 2024
1 parent 9ac26e8 commit 1f3a061
Showing 1 changed file with 17 additions and 29 deletions.
46 changes: 17 additions & 29 deletions Ginger/GingerCoreNET/Database/NoSqlBase/GingerCassandra.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ limitations under the License.
using GingerCore.Actions;
using GingerCore.NoSqlBase.DataAccess;
using HBaseNet.Const;
using Microsoft.Graph;
using Microsoft.Graph.SecurityNamespace;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -49,37 +51,23 @@ public override bool Connect()
int queryTimeout = 20000;//default timeout (20 seconds).
string[] queryArray = Db.DatabaseOperations.TNSCalculated.Split(';');
SSLOptions sslOptions = null;
if (queryArray.Length > 1)
for (int i = 1; i < Math.Min(queryArray.Length, 3); i++)
{
if (queryArray[1].ToLower().Contains(queryTimeoutString))
switch (queryArray[i])

Check failure on line 56 in Ginger/GingerCoreNET/Database/NoSqlBase/GingerCassandra.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Ginger/GingerCoreNET/Database/NoSqlBase/GingerCassandra.cs#L56

Add a 'default' clause to this 'switch' statement.

Check notice on line 56 in Ginger/GingerCoreNET/Database/NoSqlBase/GingerCassandra.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

Ginger/GingerCoreNET/Database/NoSqlBase/GingerCassandra.cs#L56

Replace this 'switch' statement with 'if' statements to increase readability.
{
string queryTimeoutValue = queryArray[1].Substring(queryArray[1].ToLower().IndexOf(queryTimeoutString) + queryTimeoutString.Length);
if (!int.TryParse(queryTimeoutValue, out int timeout))
{
throw new ArgumentException("Query timeout value is not a valid integer.");
}
queryTimeout = Convert.ToInt32(queryTimeoutValue) * 1000;
}else if(queryArray[1].ToLower().Contains(sslString))
{
string sslValue = queryArray[1].Substring(queryArray[1].ToLower().IndexOf(sslString) + sslString.Length);
sslOptions = SetupSslOptions(sslValue);
}
}
if (queryArray.Length > 2)
{
if (queryArray[2].ToLower().Contains(queryTimeoutString))
{
string queryTimeoutValue = queryArray[2].Substring(queryArray[2].ToLower().IndexOf(queryTimeoutString) + queryTimeoutString.Length);
if (!int.TryParse(queryTimeoutValue, out int timeout))
{
throw new ArgumentException("Query timeout value is not a valid integer.");
}
queryTimeout = Convert.ToInt32(queryTimeoutValue) * 1000;
}
else if (queryArray[2].ToLower().Contains(sslString))
{
string sslValue = queryArray[2].Substring(queryArray[2].ToLower().IndexOf(sslString) + sslString.Length);
sslOptions = SetupSslOptions(sslValue);
case var str when str.Contains(queryTimeoutString):
string queryTimeoutValue = str.Substring(str.IndexOf(queryTimeoutString) + queryTimeoutString.Length);
if (!int.TryParse(queryTimeoutValue, out int timeout))
{
throw new ArgumentException("Query timeout value is not a valid integer.");
}
queryTimeout = Convert.ToInt32(queryTimeoutValue) * 1000;
break;

case var str when str.Contains(sslString):
string sslValue = str.Substring(str.IndexOf(sslString) + sslString.Length);
sslOptions = SetupSslOptions(sslValue);
break;
}
}
string[] HostKeySpace = queryArray[0].ToLower().Replace("http://", "").Replace("https://", "").Split('/');
Expand Down

0 comments on commit 1f3a061

Please sign in to comment.