yoyo-project/yoyo

View on GitHub

Showing 32 of 52 total issues

Method Table.validate has 8 return statements (exceeds 4 allowed).
Open

func (t *Table) validate() (err error) {
    if err = validateName(t.Name); err != nil {
        return err
    }

Severity: Major
Found in internal/schema/schema_validate.go - About 50 mins to fix

    Method Column.validate has 8 return statements (exceeds 4 allowed).
    Open

    func (c *Column) validate() error {
        if err := validateName(c.Name); err != nil {
            return err
        }
    
    
    Severity: Major
    Found in internal/schema/schema_validate.go - About 50 mins to fix

      Function FindPackagePath has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
      Open

      func FindPackagePath(path string) (string, error) {
          gopath := os.Getenv("GOPATH")
          var str, p string
          for p = path; len(p) > 4; p = filepath.Dir(p) {
              str = func(p string) string {
      Severity: Minor
      Found in internal/file/files.go - About 45 mins 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 adapter.GetColumn has 6 return statements (exceeds 4 allowed).
      Open

      func (a *adapter) GetColumn(tableName, colName string) (schema.Column, error) {
          var (
              dt         string
              nullable   string
              key        = new(string)
      Severity: Major
      Found in internal/dbms/mysql/adapter_reverse.go - About 40 mins to fix

        Method Database.validate has 6 return statements (exceeds 4 allowed).
        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: Major
        Found in internal/schema/schema_validate.go - About 40 mins to fix

          Function NewEntityRepositoryGenerator has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          func NewEntityRepositoryGenerator(packageName string, adapter Adapter, reposPath string, packagePath Finder, db schema.Database) EntityGenerator {
          Severity: Minor
          Found in internal/repository/generate_repository.go - About 35 mins to fix

            Method CityRepository.Search has 5 return statements (exceeds 4 allowed).
            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 - About 35 mins to fix

              Method NoPkTableRepository.Search has 5 return statements (exceeds 4 allowed).
              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 - About 35 mins to fix

                Method Reference.validate has 5 return statements (exceeds 4 allowed).
                Open

                func (r *Reference) validate() error {
                    if err := validateName(r.GoName); err != nil {
                        return err
                    }
                    if r.HasMany == r.HasOne {
                Severity: Major
                Found in internal/schema/schema_validate.go - About 35 mins to fix

                  Function FindPackagePath has 5 return statements (exceeds 4 allowed).
                  Open

                  func FindPackagePath(path string) (string, error) {
                      gopath := os.Getenv("GOPATH")
                      var str, p string
                      for p = path; len(p) > 4; p = filepath.Dir(p) {
                          str = func(p string) string {
                  Severity: Major
                  Found in internal/file/files.go - About 35 mins to fix

                    Method PersonRepository.Search has 5 return statements (exceeds 4 allowed).
                    Open

                    func (r *PersonRepository) Search(query person.Query) (es Persons, 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_person.go - About 35 mins to fix

                      Function NewQueryFileGenerator has a Cognitive Complexity of 21 (exceeds 20 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 25 mins 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

                      Severity
                      Category
                      Status
                      Source
                      Language