Showing 77 of 198 total issues
Method InstallPackages
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private void InstallPackages(string[] packageList)
{
TLog.MethodStart();
int num = packageList.Length;
for (int i = 0; i < num; i++)
Method InitializeObjectivesAndVariables
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private void InitializeObjectivesAndVariables()
{
Util.GrasshopperInOut ghIO = SharedItems.Component.GhInOut;
ObjectiveSettingItems = new ObservableCollection<ObjectiveSettingItem>();
foreach (string item in ghIO.Objectives.GetNickNames())
Method ProgressStatePropertiesTest
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
[Fact]
public void ProgressStatePropertiesTest()
{
var param = new List<Input.Parameter>();
double[][] bests = new double[1][];
Method FilterInputVariables
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private bool FilterInputVariables()
{
TLog.MethodStart();
var errorInputGuids = new List<Guid>();
foreach ((IGH_DocumentObject docObject, int _) in _inputGuids.Select((guid, i) => (_document.FindObject(guid, false), i)))
Consider simplifying this complex logical expression. Open
Open
if (
(samplerType == SamplerType.GP || samplerType == SamplerType.CmaEs || samplerType == SamplerType.QMC || samplerType == SamplerType.Random || samplerType == SamplerType.AUTO || samplerType == SamplerType.BruteForce)
&& hasConstraints
)
{
Method SetProgressState
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
private ProgressState SetProgressState(OptimizationHandlingInfo optSet, Parameter[] parameter, int trialNum, DateTime startTime, TrialWrapper trial, Pruner pruner, int progress)
Method CreateStudy
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
public static StudyWrapper CreateStudy(string studyName, dynamic sampler, string[] directions, dynamic storage, dynamic pruner, bool loadIfExists)
Method PreferentialOptimization
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
private void PreferentialOptimization(int nBatch, dynamic storage, dynamic artifactBackend, out Parameter[] parameter, out TrialGrasshopperItems result, out StudyWrapper study)
Avoid deeply nested control flow statements. Open
Open
if (target == $"Attr: {k}_{i}")
{
return values[i];
}
Consider simplifying this complex logical expression. Open
Open
if (StudyNameItems.Count == 0 || SelectedStudyName == null ||
SelectedObjective == null || ObjectiveItems.Count == 0 ||
VariableItems.Count == 0 || !VariableItems.Any(v => v.IsSelected))
{
plotSettings = null;
Method TellResultToOptuna
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
private void TellResultToOptuna(OptimizationHandlingInfo optInfo, Parameter[] parameter, int trialNum, TrialWrapper trial, TrialGrasshopperItems result)
Method PlotParamImportances
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
public static PlotlyFigure PlotParamImportances(StudyWrapper study, string objectiveName, int objectiveIndex, string[] variableNames, string evaluator)
Method TellCompleted
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
private void TellCompleted(OptimizationHandlingInfo optInfo, Parameter[] parameter, int trialNum, TrialWrapper trial, TrialGrasshopperItems result)
Function plot_cluster_nd
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def plot_cluster_nd(
Method RunSingleOptimizeStep
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
private TrialGrasshopperItems RunSingleOptimizeStep(OptimizationHandlingInfo optInfo, Parameter[] parameter, int trialNum, DateTime startTime)
{
TLog.MethodStart();
dynamic optuna = Py.Import("optuna");
TrialWrapper trial;
- 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
Avoid too many return
statements within this method. Open
Open
return result;
Avoid too many return
statements within this method. Open
Open
return trial.Values[i];