Showing 32 of 52 total issues
Method Table.validate
has 8 return statements (exceeds 4 allowed). Open
Open
func (t *Table) validate() (err error) {
if err = validateName(t.Name); err != nil {
return err
}
Method Column.validate
has 8 return statements (exceeds 4 allowed). Open
Open
func (c *Column) validate() error {
if err := validateName(c.Name); err != nil {
return err
}
Function FindPackagePath
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
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 {
- Read upRead up
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
Open
func (a *adapter) GetColumn(tableName, colName string) (schema.Column, error) {
var (
dt string
nullable string
key = new(string)
Method Database.validate
has 6 return statements (exceeds 4 allowed). Open
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)
Function NewEntityRepositoryGenerator
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func NewEntityRepositoryGenerator(packageName string, adapter Adapter, reposPath string, packagePath Finder, db schema.Database) EntityGenerator {
Method CityRepository.Search
has 5 return statements (exceeds 4 allowed). Open
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 {
Method NoPkTableRepository.Search
has 5 return statements (exceeds 4 allowed). Open
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 {
Method Reference.validate
has 5 return statements (exceeds 4 allowed). Open
Open
func (r *Reference) validate() error {
if err := validateName(r.GoName); err != nil {
return err
}
if r.HasMany == r.HasOne {
Function FindPackagePath
has 5 return statements (exceeds 4 allowed). Open
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 {
Method PersonRepository.Search
has 5 return statements (exceeds 4 allowed). Open
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 {
Function NewQueryFileGenerator
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
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
- Read upRead up
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"