yoyo-project/yoyo

View on GitHub

Showing 52 of 52 total issues

Function NewGenerator has a Cognitive Complexity of 84 (exceeds 20 allowed). Consider refactoring.
Open

func NewGenerator(
    generateEntity EntityGenerator,
    generateRepository EntityGenerator,
    generateQueryFile EntityGenerator,
    generateRepositoriesFile WriteGenerator,
Severity: Minor
Found in internal/repository/generate.go - About 1 day 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 InitDatabaseReader has a Cognitive Complexity of 59 (exceeds 20 allowed). Consider refactoring.
Open

func InitDatabaseReader(loadAdapter AdapterLoader) DatabaseReader {
    return func(config yoyo.Config) (db schema.Database, err error) {
        var adapter Adapter
        adapter, err = loadAdapter(config.Schema.Dialect)
        if err != nil {
Severity: Minor
Found in internal/reverse/schema.go - About 6 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

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

package repositories

import (
    "database/sql"
    "fmt"
Severity: Major
Found in example/mysql/yoyo/repositories/entity_no_pk_table.go and 1 other location - About 6 hrs to fix
example/mysql/yoyo/repositories/entity_city.go on lines 1..68

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

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

package repositories

import (
    "database/sql"
    "fmt"
Severity: Major
Found in example/mysql/yoyo/repositories/entity_city.go and 1 other location - About 6 hrs to fix
example/mysql/yoyo/repositories/entity_no_pk_table.go on lines 1..68

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

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

Query has 46 methods (exceeds 20 allowed). Consider refactoring.
Open

type Query struct {
    n query.Node
}
Severity: Minor
Found in example/mysql/yoyo/repositories/query/person/query.go - About 6 hrs to fix

    File query.go has 676 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    package person
    
    import (
        "fmt"
    
    
    Severity: Minor
    Found in example/mysql/yoyo/repositories/query/person/query.go - About 6 hrs to fix

      Function NewEntityRepositoryGenerator has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
      Open

      func NewEntityRepositoryGenerator(packageName string, adapter Adapter, reposPath string, packagePath Finder, db schema.Database) EntityGenerator {
          return func(t schema.Table, w io.StringWriter) (err error) {
              var pkNames, insertCNames, selectCNames, scanFields, inFields, pkFields, colAssignments []string
              for _, col := range t.Columns {
                  if col.PrimaryKey {
      Severity: Minor
      Found in internal/repository/generate_repository.go - About 4 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

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

      func (r *CityRepository) Search(query city.Query) (es Citys, err error) {
          var stmt *sql.Stmt
          // ensure the *sql.Stmt is closed after we're done with it
          defer func() {
              if stmt != nil && r.tx == nil {
      Severity: Major
      Found in example/mysql/yoyo/repositories/repository_city.go and 1 other location - About 4 hrs to fix
      example/mysql/yoyo/repositories/repository_no_pk_table.go on lines 49..89

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

      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

      func (r *NoPkTableRepository) Search(query no_pk_table.Query) (es NoPkTables, err error) {
          var stmt *sql.Stmt
          // ensure the *sql.Stmt is closed after we're done with it
          defer func() {
              if stmt != nil && r.tx == nil {
      Severity: Major
      Found in example/mysql/yoyo/repositories/repository_no_pk_table.go and 1 other location - About 4 hrs to fix
      example/mysql/yoyo/repositories/repository_city.go on lines 49..89

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

      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

      Function NewGenerator has 125 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func NewGenerator(
          generateEntity EntityGenerator,
          generateRepository EntityGenerator,
          generateQueryFile EntityGenerator,
          generateRepositoriesFile WriteGenerator,
      Severity: Major
      Found in internal/repository/generate.go - About 4 hrs to fix

        Function NewEntityRepositoryGenerator has 117 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func NewEntityRepositoryGenerator(packageName string, adapter Adapter, reposPath string, packagePath Finder, db schema.Database) EntityGenerator {
            return func(t schema.Table, w io.StringWriter) (err error) {
                var pkNames, insertCNames, selectCNames, scanFields, inFields, pkFields, colAssignments []string
                for _, col := range t.Columns {
                    if col.PrimaryKey {
        Severity: Major
        Found in internal/repository/generate_repository.go - About 3 hrs to fix

          Method Table.UnmarshalYAML has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring.
          Open

          func (t *Table) UnmarshalYAML(value *yaml.Node) (err error) {
              for i, n := range value.Content {
                  switch n.Value {
                  case "columns":
                      colsNode := value.Content[i+1]
          Severity: Minor
          Found in internal/schema/schema_unmarshal.go - 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 Database.validate has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
          Open

          func (db *Database) validate() (err error) {
              tNames := make(map[string]bool)
              for _, t := range db.Tables {
                  if err = t.validate(); err != nil {
                      return fmt.Errorf("%w for table `%s`", err, t.Name)
          Severity: Minor
          Found in internal/schema/schema_validate.go - 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

          Function NewGenerator has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
          Open

          func NewGenerator(
              createTable TableGenerator,
              addMissingColumns TableGenerator,
              addMissingIndices TableGenerator,
              addAllIndices TableGenerator,
          Severity: Minor
          Found in internal/migration/generator.go - 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

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

          func (r *CityRepository) FetchOne(query city.Query) (ent City, err error) {
              var stmt *sql.Stmt
              // ensure the *sql.Stmt is closed after we're done with it
              defer func() {
                  if stmt != nil && r.tx == nil {
          Severity: Major
          Found in example/mysql/yoyo/repositories/repository_city.go and 1 other location - About 2 hrs to fix
          example/mysql/yoyo/repositories/repository_no_pk_table.go on lines 24..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 208.

          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

          func (r *NoPkTableRepository) FetchOne(query no_pk_table.Query) (ent NoPkTable, err error) {
              var stmt *sql.Stmt
              // ensure the *sql.Stmt is closed after we're done with it
              defer func() {
                  if stmt != nil && r.tx == nil {
          Severity: Major
          Found in example/mysql/yoyo/repositories/repository_no_pk_table.go and 1 other location - About 2 hrs to fix
          example/mysql/yoyo/repositories/repository_city.go on lines 24..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 208.

          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

          Function NewEntityGenerator has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
          Open

          func NewEntityGenerator(packageName string, db schema.Database, packagePath Finder, reposPath string) EntityGenerator {
              return func(t schema.Table, w io.StringWriter) error {
                  var fields, referenceFields, scanFields, imports []string
                  nullPackagePath, err := packagePath(reposPath + "/nullable")
                  if err != nil {
          Severity: Minor
          Found in internal/repository/generate_entity.go - 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

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

                      err = func() error {
                          fName := filepath.Join(repositoriesPath, fmt.Sprintf("repository_%s.go", t.QueryPackageName()))
                          f, err := create(fName)
                          defer func() {
                              if f != nil {
          Severity: Major
          Found in internal/repository/generate.go and 1 other location - About 1 hr to fix
          internal/repository/generate.go on lines 36..53

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

          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

                      err := func() error {
                          fName := filepath.Join(repositoriesPath, fmt.Sprintf("entity_%s.go", t.QueryPackageName()))
                          f, err := create(fName)
                          defer func() {
                              if f != nil {
          Severity: Major
          Found in internal/repository/generate.go and 1 other location - About 1 hr to fix
          internal/repository/generate.go on lines 58..75

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

          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

          func (r *CityRepository) Delete(query city.Query) (err error) {
              var stmt *sql.Stmt
              // ensure the *sql.Stmt is closed after we're done with it
              defer func() {
                  if stmt != nil && r.tx == nil {
          Severity: Major
          Found in example/mysql/yoyo/repositories/repository_city.go and 1 other location - About 1 hr to fix
          example/mysql/yoyo/repositories/repository_person.go on lines 168..186

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

          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