hrntsm/Tunny

View on GitHub

Showing 185 of 198 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        private void SetTrialUserAttrFromJObject(int trialId, JObject userAttr)
        {
            foreach (KeyValuePair<string, JToken> item in userAttr)
            {
                string[] values = item.Value.Select(v => v.ToString()).ToArray();
Severity: Major
Found in Optuna/Storage/Journal/Storage.cs and 1 other location - About 1 hr to fix
Optuna/Storage/Journal/Storage.cs on lines 192..203

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 128.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

              public static PlotlyFigure PlotSlice(StudyWrapper study, string objectiveName, int objectiveIndex, string[] variableNames)
              {
                  PyModule ps = Py.CreateScope();
                  ps.Exec(ReadFileFromResource.Text("Optuna.Visualization.Python.plot_slice.py"));
                  dynamic pyPlotSlice = ps.Get("plot_slice");
      Severity: Major
      Found in Optuna/Visualization/Visualization.cs and 3 other locations - About 1 hr to fix
      Optuna/Visualization/Visualization.cs on lines 42..49
      Optuna/Visualization/Visualization.cs on lines 69..76
      Optuna/Visualization/Visualization.cs on lines 104..111

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 122.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

              public static PlotlyFigure PlotRank(StudyWrapper study, string objectiveName, int objectiveIndex, string[] variableNames)
              {
                  PyModule ps = Py.CreateScope();
                  ps.Exec(ReadFileFromResource.Text("Optuna.Visualization.Python.plot_rank.py"));
                  dynamic pyPlotRank = ps.Get("plot_rank");
      Severity: Major
      Found in Optuna/Visualization/Visualization.cs and 3 other locations - About 1 hr to fix
      Optuna/Visualization/Visualization.cs on lines 10..17
      Optuna/Visualization/Visualization.cs on lines 42..49
      Optuna/Visualization/Visualization.cs on lines 69..76

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 122.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

              public static PlotlyFigure PlotContour(StudyWrapper study, string objectiveName, int objectiveIndex, string[] variableNames)
              {
                  PyModule ps = Py.CreateScope();
                  ps.Exec(ReadFileFromResource.Text("Optuna.Visualization.Python.plot_contour.py"));
                  dynamic pyPlotContour = ps.Get("plot_contour");
      Severity: Major
      Found in Optuna/Visualization/Visualization.cs and 3 other locations - About 1 hr to fix
      Optuna/Visualization/Visualization.cs on lines 10..17
      Optuna/Visualization/Visualization.cs on lines 42..49
      Optuna/Visualization/Visualization.cs on lines 104..111

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 122.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

              public static PlotlyFigure PlotParallelCoordinate(StudyWrapper study, string objectiveName, int objectiveIndex, string[] variableNames)
              {
                  PyModule ps = Py.CreateScope();
                  ps.Exec(ReadFileFromResource.Text("Optuna.Visualization.Python.plot_parallel_coordinate.py"));
                  dynamic pyPlotParallelCoordinate = ps.Get("plot_parallel_coordinate");
      Severity: Major
      Found in Optuna/Visualization/Visualization.cs and 3 other locations - About 1 hr to fix
      Optuna/Visualization/Visualization.cs on lines 10..17
      Optuna/Visualization/Visualization.cs on lines 69..76
      Optuna/Visualization/Visualization.cs on lines 104..111

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 122.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                private void RenderInputComponentBoxes(Graphics graphics)
                {
                    Brush fill = new SolidBrush(Color.FromArgb(Convert.ToInt32("99FFA500", 16)));
                    Pen edge = Pens.Orange;
                    foreach (Guid guid in Owner.Params.Input[0].Sources.Select(s => s.InstanceGuid))
        Tunny/Component/Operation/ConstructFishEggAttributes.cs on lines 35..43

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 120.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                private void RenderInputComponentBoxes(Graphics graphics)
                {
                    Brush fill = new SolidBrush(Color.FromArgb(Convert.ToInt32("99FFA500", 16)));
                    Pen edge = Pens.Orange;
                    foreach (Guid guid in Owner.Params.Input[0].Sources.Select(s => s.InstanceGuid))
        Severity: Major
        Found in Tunny/Component/Operation/ConstructFishEggAttributes.cs and 1 other location - About 1 hr to fix
        Tunny/Component/Operation/ConstructFishEggByCsvAttributes.cs on lines 35..43

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 120.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

                  Similar blocks of code found in 3 locations. Consider refactoring.
                  Open

                  optuna.visualization.plot_contour(
                      study,
                      params=["x", "y"],
                      target=lambda t: t.values[0],
                  Severity: Major
                  Found in Examples/Python/plot.py and 2 other locations - About 1 hr to fix
                  Examples/Python/plot.py on lines 26..29
                  Examples/Python/plot.py on lines 55..56

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 42.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 3 locations. Consider refactoring.
                  Open

                  optuna.visualization.plot_parallel_coordinate(
                      study, params=["x", "y"], target=lambda t: t.values[0], target_name=name
                  Severity: Major
                  Found in Examples/Python/plot.py and 2 other locations - About 1 hr to fix
                  Examples/Python/plot.py on lines 26..29
                  Examples/Python/plot.py on lines 44..47

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 42.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 3 locations. Consider refactoring.
                  Open

                  optuna.visualization.plot_slice(
                      study,
                      params=["x", "y"],
                      target=lambda t: t.values[0],
                  Severity: Major
                  Found in Examples/Python/plot.py and 2 other locations - About 1 hr to fix
                  Examples/Python/plot.py on lines 44..47
                  Examples/Python/plot.py on lines 55..56

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 42.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Severity
                  Category
                  Status
                  Source
                  Language