hrntsm/Tunny

View on GitHub

Showing 77 of 198 total issues

Method ToComponentEndMessage has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        private static void ToComponentEndMessage(Algorithm optimize)
        {
            TLog.MethodStart();
            string message;
            switch (optimize.EndState)
Severity: Minor
Found in Tunny/Solver/Solver.cs - About 1 hr to fix

    Method SetArtifacts has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            private bool SetArtifacts()
            {
                TLog.MethodStart();
                Artifacts = new Artifact();
                if (_component.Params.Input[3].SourceCount == 0)
    Severity: Minor
    Found in Tunny/Util/GrasshopperInOut.cs - About 1 hr to fix

      Method SetNonGeometricAttr has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              private static void SetNonGeometricAttr(TrialGrasshopperItems result, TrialWrapper trial)
              {
                  TLog.MethodStart();
                  foreach (KeyValuePair<string, List<string>> pair in result.Attribute)
                  {
      Severity: Minor
      Found in Tunny/Solver/Algorithm.cs - About 1 hr to fix

        Method ToString has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                public override string ToString()
                {
                    var sb = new StringBuilder();
                    foreach (KeyValuePair<string, object> attr in Value)
                    {
        Severity: Minor
        Found in Tunny/Type/GH_FishAttribute.cs - About 1 hr to fix

          Method ToPython has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  public dynamic ToPython(string storagePath, PyDict x0)
                  {
                      dynamic optuna = Py.Import("optuna");
          
                      return UseWarmStart
          Severity: Minor
          Found in Optuna/Sampler/CmaEsSampler.cs - About 1 hr to fix

            Method GetParetoFrontTrials2D has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            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;
            Severity: Minor
            Found in Optuna/Study/MultiObjective.cs - About 1 hr to fix

              Method GetAttributes has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      public Dictionary<string, List<string>> GetAttributes()
                      {
                          TLog.MethodStart();
                          var attrs = new Dictionary<string, List<string>>();
                          if (_attributes.Value == null)
              Severity: Minor
              Found in Tunny/Util/GrasshopperInOut.cs - About 1 hr to fix

                Method SetOptimizationParameter has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        private void SetOptimizationParameter(Parameter[] parameter, TrialWrapper trial)
                        {
                            TLog.MethodStart();
                            foreach ((VariableBase variable, int i) in _variables.Select((v, i) => (v, i)))
                            {
                Severity: Minor
                Found in Tunny/Solver/Algorithm.cs - About 1 hr to fix

                  Method Plot has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          internal static string Plot(Storage storage, PlotSettings plotSettings, string htmlPath = "")
                          {
                              TLog.MethodStart();
                              InitializePythonEngine();
                              using (Py.GIL())
                  Severity: Minor
                  Found in Tunny/Process/VisualizeProcess.cs - About 1 hr to fix

                    Method SetAttributeEachItem has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            private void SetAttributeEachItem(StringBuilder sb, KeyValuePair<string, object> attr)
                            {
                                var valueStrings = new StringBuilder();
                                if (attr.Key == "Geometry")
                                {
                    Severity: Minor
                    Found in Tunny/Type/GH_Fish.cs - About 1 hr to fix

                      Method SetParamsValue has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      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)))
                                  {
                      Severity: Minor
                      Found in Tunny/Input/Objective.cs - About 1 hr to fix

                        Method CreateFigure has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                private static PlotlyFigure CreateFigure(StudyWrapper study, PlotSettings settings)
                                {
                                    TLog.MethodStart();
                                    switch (settings.PlotTypeName)
                                    {
                        Severity: Minor
                        Found in Tunny/Process/VisualizeProcess.cs - About 1 hr to fix

                          Method NormalOptimization has 9 arguments (exceeds 4 allowed). Consider refactoring.
                          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)
                          Severity: Major
                          Found in Tunny/Solver/Algorithm.cs - About 1 hr to fix

                            Method HumanSliderInputOptimization has 9 arguments (exceeds 4 allowed). Consider refactoring.
                            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)
                            Severity: Major
                            Found in Tunny/Solver/Algorithm.cs - About 1 hr to fix

                              Method GetStudyDirections has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                      public StudyDirection[] GetStudyDirections(int studyId)
                                      {
                                          if (_studies.TryGetValue(studyId, out Study.Study value))
                                          {
                                              return value.Directions;
                              Severity: Minor
                              Found in Optuna/Storage/RDB/Storage.cs - About 1 hr to fix

                                Method AddVariablesToFishEgg has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                        private void AddVariablesToFishEgg(Dictionary<string, double[]> variableRange, IEnumerable<Dictionary<string, string>> csvData)
                                        {
                                
                                            foreach (Dictionary<string, string> data in csvData)
                                            {
                                Severity: Minor
                                Found in Tunny/Component/Operation/ConstructFishEggByCsv.cs - About 1 hr to fix

                                  Method SetTrialUserAttr has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                          private static void SetTrialUserAttr(TrialGrasshopperItems result, TrialWrapper trial, OptimizationHandlingInfo optSet)
                                          {
                                              TLog.MethodStart();
                                              if (result.GeometryJson.Length != 0)
                                              {
                                  Severity: Minor
                                  Found in Tunny/Solver/Algorithm.cs - About 1 hr to fix

                                    Function truncate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                    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
                                    Severity: Minor
                                    Found in Optuna/Visualization/Python/plot_pareto_front.py - About 1 hr 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

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

                                            private bool SetObjectives()
                                            {
                                                TLog.MethodStart();
                                                if (_component.Params.Input[1].SourceCount == 0)
                                                {
                                    Severity: Minor
                                    Found in Tunny/Util/GrasshopperInOut.cs - About 1 hr to fix

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

                                              private void TTDesignExplorerToolStripMenuItem_Click(object sender, EventArgs e)
                                              {
                                                  TLog.MethodStart();
                                                  string settingsPath = TEnvVariables.OptimizeSettingsPath;
                                                  string storagePath = string.Empty;
                                      Severity: Minor
                                      Found in Tunny/Component/LoadingInstruction/RegisterTunnyToolbarItems.cs - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language