hrntsm/Tunny

View on GitHub

Showing 77 of 198 total issues

Method SelectSampler has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        private void SelectSampler(SelectSamplerType? selectSamplerType)
        {
            SamplerType samplerType;
            switch (selectSamplerType)
            {
Severity: Major
Found in Tunny/WPF/ViewModels/MainWindowViewModel.cs - About 2 hrs to fix

    Method GetCurrentSettings has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            internal Core.Settings.Optimize GetCurrentSettings(bool computeAutoValue = false)
            {
                TLog.MethodStart();
                var sampler = new Sampler
                {
    Severity: Major
    Found in Tunny/WPF/ViewModels/Optimize/OptimizeViewModel.cs - About 2 hrs to fix

      Method GetTrial has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              public Trial.Trial GetTrial(int trialId)
              {
                  var trial = new Trial.Trial();
                  using (var connection = new SQLiteConnection(_sqliteConnection.ToString()))
                  {
      Severity: Minor
      Found in Optuna/Storage/RDB/Storage.cs - About 1 hr to fix

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

                public dynamic ToPython(SamplerType type, string storagePath, bool hasConstraints, PyDict cmaEsX0)
                {
                    TLog.MethodStart();
                    dynamic optunaSampler;
                    switch (type)
        Severity: Minor
        Found in Tunny.Core/Settings/Sampler.cs - About 1 hr to fix

          Method SolveInstance has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  protected override void SolveInstance(IGH_DataAccess DA)
                  {
                      CheckVariablesInput(Params.Input[0].Sources.Select(ghParam => ghParam.InstanceGuid));
                      CheckObjectivesInput(Params.Input[1].Sources.Select(ghParam => ghParam.InstanceGuid));
                      CheckArtifactsInput(Params.Input[3].Sources.Select(ghParam => ghParam.InstanceGuid));
          Severity: Minor
          Found in Tunny/Component/Optimizer/BoneFishComponent.cs - About 1 hr to fix

            Method SetInputSliderValues has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    private void SetInputSliderValues(List<VariableBase> variables)
                    {
                        TLog.MethodStart();
                        int i = 0;
            
            
            Severity: Minor
            Found in Tunny/Util/GrasshopperInOut.cs - About 1 hr to fix

              Method StorageLoadTest has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      [Theory]
                      [InlineData(@"TestFile/sqlite.db", "sqlite")]
                      [InlineData(@"TestFile/journal.log", "log")]
                      public void StorageLoadTest(string path, string type)
                      {
              Severity: Minor
              Found in OptunaTests/Storage/StorageSameBevaviorTests.cs - About 1 hr to fix

                Method CreateNewStudy has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        public int CreateNewStudy(StudyDirection[] studyDirections, string studyName)
                        {
                            long maxLength;
                            using (var connection = new SQLiteConnection(_sqliteConnection.ToString()))
                            {
                Severity: Minor
                Found in Optuna/Storage/RDB/Storage.cs - About 1 hr to fix

                  Method Solve has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          public void Solve()
                          {
                              TLog.MethodStart();
                              EndState = EndState.Error;
                              OptimizeProcess.IsForcedStopOptimize = false;
                  Severity: Minor
                  Found in Tunny/Solver/Algorithm.cs - About 1 hr to fix

                    Method CheckOptimizeComplete has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            private bool CheckOptimizeComplete(OptimizationHandlingInfo optInfo, int trialNum, DateTime startTime)
                            {
                                TLog.MethodStart();
                    
                                int nTrials = optInfo.NTrials;
                    Severity: Minor
                    Found in Tunny/Solver/Algorithm.cs - About 1 hr to fix

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

                              public dynamic ToPython()
                              {
                                  TLog.MethodStart();
                                  dynamic optunaPruner;
                                  dynamic optuna = Py.Import("optuna");
                      Severity: Minor
                      Found in Tunny.Core/Settings/Pruner.cs - About 1 hr to fix

                        Method GetAllStudySummaries has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                public static StudySummary[] GetAllStudySummaries(IOptunaStorage storage)
                                {
                                    Study[] studies = storage.GetAllStudies();
                                    var studySummaries = new StudySummary[studies.Length];
                                    for (int i = 0; i < studies.Length; i++)
                        Severity: Minor
                        Found in Optuna/Study/Study.cs - About 1 hr to fix

                          Function add_row_in_attr has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def add_row_in_attr(trial: FrozenTrial, row: list[str]) -> None:
                              for value in trial.user_attrs.values():
                                  if value is None:
                                      continue
                                  if isinstance(value, int) or isinstance(value, float):
                          Severity: Minor
                          Found in Tunny.Core/Handler/Python/export_fish_csv.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

                          Function set_in_attr_label has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def set_in_attr_label(label: list[str], trials: list[FrozenTrial]) -> None:
                              for key, value in trials[0].user_attrs.items():
                                  if value is None:
                                      continue
                          
                          
                          Severity: Minor
                          Found in Tunny.Core/Handler/Python/export_fish_csv.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 SetSliderValues has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                  private void SetSliderValues(decimal[] parameters)
                                  {
                                      TLog.MethodStart();
                                      int i = 0;
                          
                          
                          Severity: Minor
                          Found in Tunny/Util/GrasshopperInOut.cs - About 1 hr to fix

                            Method GetAttrs has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                    private static void GetAttrs(Dictionary<string, object> attrs, SQLiteDataReader reader)
                                    {
                                        string key = reader.GetString(0);
                                        string value = reader.GetString(1);
                                        if (!string.IsNullOrEmpty(value) && value.Contains("[") && value.Contains("]"))
                            Severity: Minor
                            Found in Optuna/Storage/RDB/Storage.cs - About 1 hr to fix

                              Method ShowUIEndMessages has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                      private static MessageBoxResult ShowUIEndMessages(EndState endState, bool isMultiObjective)
                                      {
                                          TLog.MethodStart();
                                          MessageBoxResult msgResult;
                                          MessageBoxButton button = isMultiObjective ? MessageBoxButton.OK : MessageBoxButton.YesNo;
                              Severity: Minor
                              Found in Tunny/Solver/Solver.cs - About 1 hr to fix

                                Method SelectItemUnsafe has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                        public void SelectItemUnsafe(int index)
                                        {
                                            if (index < 0 || index >= ListItems.Count)
                                            {
                                                return;
                                Severity: Minor
                                Found in Tunny/Component/Input/TunnyValueList.cs - About 1 hr to fix

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

                                          public Study.Study[] GetAllStudies()
                                          {
                                              using (var connection = new SQLiteConnection(_sqliteConnection.ToString()))
                                              {
                                                  connection.Open();
                                  Severity: Minor
                                  Found in Optuna/Storage/RDB/Storage.cs - About 1 hr to fix

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

                                            internal async static Task RunAsync(OptimizeViewModel optimizeViewModel)
                                            {
                                                TLog.MethodStart();
                                                SharedItems.Component?.GhInOutInstantiate();
                                                SharedItems.OptimizeViewModel = optimizeViewModel;
                                    Severity: Minor
                                    Found in Tunny/Process/OptimizeProcess.cs - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language