Showing 77 of 198 total issues
Method ToComponentEndMessage
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private static void ToComponentEndMessage(Algorithm optimize)
{
TLog.MethodStart();
string message;
switch (optimize.EndState)
Method SetArtifacts
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private bool SetArtifacts()
{
TLog.MethodStart();
Artifacts = new Artifact();
if (_component.Params.Input[3].SourceCount == 0)
Method SetNonGeometricAttr
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private static void SetNonGeometricAttr(TrialGrasshopperItems result, TrialWrapper trial)
{
TLog.MethodStart();
foreach (KeyValuePair<string, List<string>> pair in result.Attribute)
{
Method ToString
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public override string ToString()
{
var sb = new StringBuilder();
foreach (KeyValuePair<string, object> attr in Value)
{
Method ToPython
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public dynamic ToPython(string storagePath, PyDict x0)
{
dynamic optuna = Py.Import("optuna");
return UseWarmStart
Method GetParetoFrontTrials2D
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private static Trial.Trial[] GetParetoFrontTrials2D(List<Trial.Trial> trials, StudyDirection[] directions)
{
List<Trial.Trial> targetTrials = trials.FindAll(trial => trial.State == TrialState.COMPLETE);
int nTrials = targetTrials.Count;
Method GetAttributes
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public Dictionary<string, List<string>> GetAttributes()
{
TLog.MethodStart();
var attrs = new Dictionary<string, List<string>>();
if (_attributes.Value == null)
Method SetOptimizationParameter
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private void SetOptimizationParameter(Parameter[] parameter, TrialWrapper trial)
{
TLog.MethodStart();
foreach ((VariableBase variable, int i) in _variables.Select((v, i) => (v, i)))
{
Method Plot
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
internal static string Plot(Storage storage, PlotSettings plotSettings, string htmlPath = "")
{
TLog.MethodStart();
InitializePythonEngine();
using (Py.GIL())
Method SetAttributeEachItem
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private void SetAttributeEachItem(StringBuilder sb, KeyValuePair<string, object> attr)
{
var valueStrings = new StringBuilder();
if (attr.Key == "Geometry")
{
Method SetParamsValue
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private static void SetParamsValue(List<IGH_Param> sources, List<double> numbers, List<Bitmap> images, List<GeometryBase> geometries)
{
TLog.MethodStart();
foreach (IGH_StructureEnumerator ghEnumerator in sources.Select(objective => objective.VolatileData.AllData(false)))
{
Method CreateFigure
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private static PlotlyFigure CreateFigure(StudyWrapper study, PlotSettings settings)
{
TLog.MethodStart();
switch (settings.PlotTypeName)
{
Method NormalOptimization
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
private void NormalOptimization(int nTrials, double timeout, string[] directions, dynamic sampler, dynamic storage, dynamic artifactBackend, out Parameter[] parameter, out TrialGrasshopperItems result, out StudyWrapper study)
Method HumanSliderInputOptimization
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
private void HumanSliderInputOptimization(int nBatch, double timeout, string[] directions, dynamic sampler, dynamic storage, dynamic artifactBackend, out Parameter[] parameter, out TrialGrasshopperItems result, out StudyWrapper study)
Method GetStudyDirections
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public StudyDirection[] GetStudyDirections(int studyId)
{
if (_studies.TryGetValue(studyId, out Study.Study value))
{
return value.Directions;
Method AddVariablesToFishEgg
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private void AddVariablesToFishEgg(Dictionary<string, double[]> variableRange, IEnumerable<Dictionary<string, string>> csvData)
{
foreach (Dictionary<string, string> data in csvData)
{
Method SetTrialUserAttr
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private static void SetTrialUserAttr(TrialGrasshopperItems result, TrialWrapper trial, OptimizationHandlingInfo optSet)
{
TLog.MethodStart();
if (result.GeometryJson.Length != 0)
{
Function truncate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
def truncate(fig, study: Study) -> go.Figure:
user_attr = study.trials[0].user_attrs
has_geometry = "Geometry" in user_attr
if has_geometry == False:
return fig
- 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 SetObjectives
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private bool SetObjectives()
{
TLog.MethodStart();
if (_component.Params.Input[1].SourceCount == 0)
{
Method TTDesignExplorerToolStripMenuItem_Click
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private void TTDesignExplorerToolStripMenuItem_Click(object sender, EventArgs e)
{
TLog.MethodStart();
string settingsPath = TEnvVariables.OptimizeSettingsPath;
string storagePath = string.Empty;