hrntsm/Tunny

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

Summary

Maintainability
D
2 days
Test Coverage

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

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

Severity: Minor
Found in Optuna/Storage/Journal/Storage.cs - About 4 hrs to fix

    Class JournalStorage has 30 methods (exceeds 20 allowed). Consider refactoring.
    Open

        public class JournalStorage : IOptunaStorage
        {
            private readonly Dictionary<int, Study.Study> _studies = new Dictionary<int, Study.Study>();
            private int _nextStudyId;
            private int _trialId;
    Severity: Minor
    Found in Optuna/Storage/Journal/Storage.cs - About 3 hrs to fix

      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

      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

      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

      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/Journal/Storage.cs and 1 other location - About 55 mins to fix
      Optuna/Storage/RDB/Storage.cs on lines 530..537

      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

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

                          case JournalOperation.SetTrialSystemAttr:
                              {
                                  int trialId = (int)logObject["trial_id"];
                                  var systemAttr = (JObject)logObject["system_attr"];
                                  SetTrialSystemAttrFromJObject(trialId, systemAttr);
      Severity: Minor
      Found in Optuna/Storage/Journal/Storage.cs and 1 other location - About 35 mins to fix
      Optuna/Storage/Journal/Storage.cs on lines 174..180

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

      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.SetTrialUserAttr:
                              {
                                  int trialId = (int)logObject["trial_id"];
                                  var userAttr = (JObject)logObject["user_attr"];
                                  SetTrialUserAttrFromJObject(trialId, userAttr);
      Severity: Minor
      Found in Optuna/Storage/Journal/Storage.cs and 1 other location - About 35 mins to fix
      Optuna/Storage/Journal/Storage.cs on lines 181..187

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

      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