hrntsm/Tunny

View on GitHub
Optuna/Storage/RDB/Storage.cs

Summary

Maintainability
F
4 days
Test Coverage

File Storage.cs has 600 lines of code (exceeds 250 allowed). Consider refactoring.
Open

using System;
using System.Collections.Generic;
using System.Data.SQLite;
using System.IO;
using System.Linq;
Severity: Major
Found in Optuna/Storage/RDB/Storage.cs - About 1 day to fix

    Class SqliteStorage has 32 methods (exceeds 20 allowed). Consider refactoring.
    Open

        public class SqliteStorage : IOptunaStorage
        {
            private readonly Dictionary<int, Study.Study> _studies = new Dictionary<int, Study.Study>();
            private readonly SQLiteConnectionStringBuilder _sqliteConnection;
            private int _nextStudyId;
    Severity: Minor
    Found in Optuna/Storage/RDB/Storage.cs - About 4 hrs to fix

      Method CreateBaseTables has 90 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              private void CreateBaseTables()
              {
                  var commands = new StringBuilder();
                  commands.Append("CREATE TABLE IF NOT EXISTS alembic_version(");
                  commands.Append("   version_num VARCHAR(32) PRIMARY KEY NOT NULL");
      Severity: Major
      Found in Optuna/Storage/RDB/Storage.cs - About 3 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 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 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 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 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

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

                          public Dictionary<string, object> GetStudyUserAttrs(int studyId)
                          {
                              var studyUserAttrs = 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 392..413
                  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> 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> 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

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

                              if (directions[0] == StudyDirection.Maximize)
                              {
                                  return allTrials.OrderByDescending(trial => trial.Values[0]).First();
                              }
                              else
                  Severity: Minor
                  Found in Optuna/Storage/RDB/Storage.cs and 1 other location - About 55 mins to fix
                  Optuna/Storage/Journal/Storage.cs on lines 273..280

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

                  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

                              {
                                  if (value.Contains("\""))
                                  {
                                      value = value.Replace("\"", "");
                                  }
                  Severity: Minor
                  Found in Optuna/Storage/RDB/Storage.cs and 1 other location - About 35 mins to fix
                  Optuna/Storage/RDB/Storage.cs on lines 628..634

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

                  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

                                      {
                                          if (value.Contains("\""))
                                          {
                                              value = value.Replace("\"", "");
                                          }
                  Severity: Minor
                  Found in Optuna/Storage/RDB/Storage.cs and 1 other location - About 35 mins to fix
                  Optuna/Storage/RDB/Storage.cs on lines 638..644

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

                  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

                  There are no issues that match your filters.

                  Category
                  Status