hrntsm/Tunny

View on GitHub

Showing 123 of 131 total issues

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

        private void SetNsga2Settings(NSGAIISampler nsga)
        {
            TLog.MethodStart();
            nsga2MutationProbCheckBox.Checked = nsga.MutationProb != null;
            nsga2MutationProbUpDown.Enabled = nsga2MutationProbCheckBox.Checked;
Severity: Major
Found in Tunny/UI/Tab/SettingsTab.cs and 1 other location - About 2 hrs to fix
Tunny/UI/Tab/SettingsTab.cs on lines 172..185

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 168.

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 2 locations. Consider refactoring.
Open

        private void SetNsga3Settings(NSGAIIISampler nsga)
        {
            TLog.MethodStart();
            nsga3MutationProbCheckBox.Checked = nsga.MutationProb != null;
            nsga3MutationProbUpDown.Enabled = nsga3MutationProbCheckBox.Checked;
Severity: Major
Found in Tunny/UI/Tab/SettingsTab.cs and 1 other location - About 2 hrs to fix
Tunny/UI/Tab/SettingsTab.cs on lines 157..170

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 168.

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 Dictionary<string, object> GetStudySystemAttrs(int studyId)
        {
            var studySystemAttrs = new Dictionary<string, object>();
            using (var connection = new SQLiteConnection(_sqliteConnection.ToString()))
            {
Severity: Major
Found in Optuna/Storage/RDB/Storage.cs and 3 other locations - About 2 hrs to fix
Optuna/Storage/RDB/Storage.cs on lines 369..390
Optuna/Storage/RDB/Storage.cs on lines 563..584
Optuna/Storage/RDB/Storage.cs on lines 586..607

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 168.

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 Dictionary<string, object> GetTrialUserAttrs(int trialId)
        {
            var trialUserAttrs = new Dictionary<string, object>();
            using (var connection = new SQLiteConnection(_sqliteConnection.ToString()))
            {
Severity: Major
Found in Optuna/Storage/RDB/Storage.cs and 3 other locations - About 2 hrs to fix
Optuna/Storage/RDB/Storage.cs on lines 369..390
Optuna/Storage/RDB/Storage.cs on lines 392..413
Optuna/Storage/RDB/Storage.cs on lines 586..607

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 168.

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 Dictionary<string, object> GetTrialSystemAttrs(int trialId)
        {
            var trialSystemAttrs = new Dictionary<string, object>();
            using (var connection = new SQLiteConnection(_sqliteConnection.ToString()))
            {
Severity: Major
Found in Optuna/Storage/RDB/Storage.cs and 3 other locations - About 2 hrs to fix
Optuna/Storage/RDB/Storage.cs on lines 369..390
Optuna/Storage/RDB/Storage.cs on lines 392..413
Optuna/Storage/RDB/Storage.cs on lines 563..584

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 168.

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 2 locations. Consider refactoring.
Open

                    case JournalOperation.SetStudyUserAttr:
                        {
                            int studyId = (int)logObject["study_id"];
                            var userAttr = (JObject)logObject["user_attr"];
                            foreach (KeyValuePair<string, JToken> item in userAttr)
Severity: Major
Found in Optuna/Storage/Journal/Storage.cs and 1 other location - About 2 hrs to fix
Optuna/Storage/Journal/Storage.cs on lines 82..96

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 166.

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 2 locations. Consider refactoring.
Open

                    case JournalOperation.SetStudySystemAttr:
                        {
                            int studyId = (int)logObject["study_id"];
                            var systemAttr = (JObject)logObject["system_attr"];
                            foreach (KeyValuePair<string, JToken> item in systemAttr)
Severity: Major
Found in Optuna/Storage/Journal/Storage.cs and 1 other location - About 2 hrs to fix
Optuna/Storage/Journal/Storage.cs on lines 67..81

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 166.

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 RunSingleOptimizeStep has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
Open

        private TrialGrasshopperItems RunSingleOptimizeStep(OptimizationHandlingInfo optInfo, Parameter[] parameter, int trialNum, DateTime startTime)
        {
            TLog.MethodStart();
            dynamic trial;
            int progress = trialNum * 100 / optInfo.NTrials;
Severity: Minor
Found in Tunny/Solver/Algorithm.cs - About 2 hrs 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 SolveInstance has 54 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: Major
Found in Tunny/Component/Optimizer/BoneFishComponent.cs - About 2 hrs to fix

    File OptimizeTab.cs has 252 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    using System;
    using System.ComponentModel;
    using System.Globalization;
    using System.IO;
    using System.Linq;
    Severity: Minor
    Found in Tunny/UI/Tab/OptimizeTab.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 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 Solve has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  public void Solve()
                  {
                      TLog.MethodStart();
                      EndState = EndState.Error;
                      OptimizeLoop.IsForcedStopOptimize = false;
          Severity: Minor
          Found in Tunny/Solver/Algorithm.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 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 SetUIValues has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        private void SetUIValues()
                        {
                            TLog.MethodStart();
                            TLog.Info("Set UI values");
                            HumanInTheLoopType type = _component.GhInOut.Objectives.HumanInTheLoopType;
                Severity: Minor
                Found in Tunny/UI/OptimizationWindow.cs - About 1 hr to fix

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

                          private void SetTrialSystemAttrFromJObject(int trialId, JObject systemAttr)
                          {
                              foreach (KeyValuePair<string, JToken> item in systemAttr)
                              {
                                  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 205..216

                  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

                  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 CreateFigure has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          private Visualization CreateFigure(dynamic study, Plot pSettings)
                          {
                              TLog.MethodStart();
                              var visualize = new Visualization(study);
                              switch (pSettings.PlotTypeName)
                  Severity: Minor
                  Found in Tunny/Solver/Visualize.cs - About 1 hr to fix

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

                            internal static void Run(object sender, DoWorkEventArgs e)
                            {
                                TLog.MethodStart();
                                s_worker = sender as BackgroundWorker;
                                Component = e.Argument as UIOptimizeComponentBase;
                    Severity: Minor
                    Found in Tunny/Handler/OutputLoop.cs - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language