yoyo-project/yoyo

View on GitHub

Showing 32 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

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

      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

          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

          Function GenerateQueryLogic has 58 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func GenerateQueryLogic(col string, column schema.Column) (methods, functions, imports []string) {
              var (
                  ops    []operation
                  goType string
              )
          Severity: Minor
          Found in internal/repository/template/query.go - About 1 hr to fix

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

            func (t *Table) validate() (err error) {
                if err = validateName(t.Name); err != nil {
                    return err
                }
            
            
            Severity: Minor
            Found in internal/schema/schema_validate.go - 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 Datatype.String has 55 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (dt Datatype) String() (s string) {
                switch dt {
                case Integer:
                    s = integer
                case TinyInt:
            Severity: Minor
            Found in internal/datatype/datatypes.go - About 1 hr to fix

              Function FromString has 55 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func FromString(in string) (dt Datatype, err error) {
                  switch strings.ToUpper(strings.Split(in, "(")[0]) {
                  case integer, sint:
                      dt = Integer
                  case bigint:
              Severity: Minor
              Found in internal/datatype/datatypes.go - About 1 hr to fix

                Function InitDatabaseReader has 54 lines of code (exceeds 50 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 1 hr to fix

                  Function NewQueryFileGenerator has 53 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func NewQueryFileGenerator(reposPath string, findPackagePath Finder, db schema.Database) EntityGenerator {
                      return func(t schema.Table, w io.StringWriter) error {
                          var methods, functions, imports []string
                  
                          // We always need fmt
                  Severity: Minor
                  Found in internal/repository/generate_query.go - About 1 hr to fix

                    Function NewEntityGenerator has 51 lines of code (exceeds 50 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 1 hr to fix

                      Function NewGenerator has 7 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          generateEntity EntityGenerator,
                          generateRepository EntityGenerator,
                          generateQueryFile EntityGenerator,
                          generateRepositoriesFile WriteGenerator,
                          generateQueryNodeFile SimpleWriteGenerator,
                      Severity: Major
                      Found in internal/repository/generate.go - About 50 mins to fix

                        Function NewGenerator has 7 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            createTable TableGenerator,
                            addMissingColumns TableGenerator,
                            addMissingIndices TableGenerator,
                            addAllIndices TableGenerator,
                            hasTable StringSearcher,
                        Severity: Major
                        Found in internal/migration/generator.go - About 50 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language