hrntsm/Tunny

View on GitHub

Showing 77 of 198 total issues

Method InstallPackages has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        private void InstallPackages(string[] packageList)
        {
            TLog.MethodStart();
            int num = packageList.Length;
            for (int i = 0; i < num; i++)
Severity: Minor
Found in Tunny/WPF/Common/PythonInstaller.cs - About 1 hr to fix

    Method InitializeObjectivesAndVariables has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            private void InitializeObjectivesAndVariables()
            {
                Util.GrasshopperInOut ghIO = SharedItems.Component.GhInOut;
                ObjectiveSettingItems = new ObservableCollection<ObjectiveSettingItem>();
                foreach (string item in ghIO.Objectives.GetNickNames())
    Severity: Minor
    Found in Tunny/WPF/ViewModels/Optimize/OptimizeViewModel.cs - About 1 hr to fix

      Method ProgressStatePropertiesTest has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              [Fact]
              public void ProgressStatePropertiesTest()
              {
                  var param = new List<Input.Parameter>();
                  double[][] bests = new double[1][];
      Severity: Minor
      Found in Tunny.CoreTests/Handler/ProgressStateTests.cs - About 1 hr to fix

        Method FilterInputVariables has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        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)))
        Severity: Minor
        Found in Tunny/Util/GrasshopperInOut.cs - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                      if (
                          (samplerType == SamplerType.GP || samplerType == SamplerType.CmaEs || samplerType == SamplerType.QMC || samplerType == SamplerType.Random || samplerType == SamplerType.AUTO || samplerType == SamplerType.BruteForce)
                          && hasConstraints
                      )
                      {
          Severity: Major
          Found in Tunny/Solver/Algorithm.cs - About 1 hr to fix

            Method SetProgressState has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    private ProgressState SetProgressState(OptimizationHandlingInfo optSet, Parameter[] parameter, int trialNum, DateTime startTime, TrialWrapper trial, Pruner pruner, int progress)
            Severity: Major
            Found in Tunny/Solver/Algorithm.cs - About 50 mins to fix

              Method CreateStudy has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      public static StudyWrapper CreateStudy(string studyName, dynamic sampler, string[] directions, dynamic storage, dynamic pruner, bool loadIfExists)
              Severity: Minor
              Found in Optuna/Study/StudyWrapper.cs - About 45 mins to fix

                Method PreferentialOptimization has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        private void PreferentialOptimization(int nBatch, dynamic storage, dynamic artifactBackend, out Parameter[] parameter, out TrialGrasshopperItems result, out StudyWrapper study)
                Severity: Minor
                Found in Tunny/Solver/Algorithm.cs - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                              if (target == $"Attr: {k}_{i}")
                                              {
                                                  return values[i];
                                              }
                  Severity: Major
                  Found in Tunny/WPF/ViewModels/Output/AnalysisChartViewModel.cs - About 45 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                                if (StudyNameItems.Count == 0 || SelectedStudyName == null ||
                                    SelectedObjective == null || ObjectiveItems.Count == 0 ||
                                    VariableItems.Count == 0 || !VariableItems.Any(v => v.IsSelected))
                                {
                                    plotSettings = null;
                    Severity: Major
                    Found in Tunny/WPF/ViewModels/Visualize/ParallelCoordinateViewModel.cs - About 40 mins to fix

                      Method TellResultToOptuna has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                              private void TellResultToOptuna(OptimizationHandlingInfo optInfo, Parameter[] parameter, int trialNum, TrialWrapper trial, TrialGrasshopperItems result)
                      Severity: Minor
                      Found in Tunny/Solver/Algorithm.cs - About 35 mins to fix

                        Method PlotParamImportances has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                                public static PlotlyFigure PlotParamImportances(StudyWrapper study, string objectiveName, int objectiveIndex, string[] variableNames, string evaluator)
                        Severity: Minor
                        Found in Optuna/Visualization/Visualization.cs - About 35 mins to fix

                          Method TellCompleted has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                                  private void TellCompleted(OptimizationHandlingInfo optInfo, Parameter[] parameter, int trialNum, TrialWrapper trial, TrialGrasshopperItems result)
                          Severity: Minor
                          Found in Tunny/Solver/Algorithm.cs - About 35 mins to fix

                            Function plot_cluster_nd has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            def plot_cluster_nd(
                            Severity: Minor
                            Found in Optuna/Visualization/Python/plot_clustering.py - About 35 mins to fix

                              Method RunSingleOptimizeStep has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                              Open

                                      private TrialGrasshopperItems RunSingleOptimizeStep(OptimizationHandlingInfo optInfo, Parameter[] parameter, int trialNum, DateTime startTime)
                                      {
                                          TLog.MethodStart();
                                          dynamic optuna = Py.Import("optuna");
                                          TrialWrapper trial;
                              Severity: Minor
                              Found in Tunny/Solver/Algorithm.cs - About 35 mins to fix

                              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

                                                          return result;
                              Severity: Major
                              Found in Tunny/WPF/ViewModels/Output/AnalysisChartViewModel.cs - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                        return trial.Values[i];
                                Severity: Major
                                Found in Tunny/WPF/ViewModels/Output/AnalysisChartViewModel.cs - About 30 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language