nikoksr/proji

View on GitHub
pkg/package/store/store.go

Summary

Maintainability
B
4 hrs
Test Coverage

Method packageStore.deepQueryPackage has 69 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (ps packageStore) deepQueryPackage(conditions string, values ...string) (pkg *domain.Package, err error) {
    rows, err := ps.db.Raw(defaultPackageDeepQueryBase+" "+conditions, values).Rows()
    if err != nil {
        return nil, err
    }
Severity: Minor
Found in pkg/package/store/store.go - About 1 hr to fix

    Method packageStore.StorePackage has 7 return statements (exceeds 4 allowed).
    Open

    func (ps packageStore) StorePackage(pkg *domain.Package) error {
        // Check if package exists
        err := ps.db.Where("label = ?", pkg.Label).First(pkg).Error
        if err == nil {
            return ErrPackageExists
    Severity: Major
    Found in pkg/package/store/store.go - About 45 mins to fix

      Method packageStore.RemovePackage has 6 return statements (exceeds 4 allowed).
      Open

      func (ps packageStore) RemovePackage(label string) error {
          tx := ps.db.Begin()
          defer func() {
              if r := recover(); r != nil {
                  tx.Rollback()
      Severity: Major
      Found in pkg/package/store/store.go - About 40 mins to fix

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

        func storeTemplates(tx *gorm.DB, templates []*domain.Template, packageID uint) error {
            insertTemplateStmt := "INSERT OR IGNORE INTO templates (created_at, updated_at, is_file, destination, path, description) VALUES (?, ?, ?, ?, ?, ?)"
            insertAssociationStmt := "INSERT OR IGNORE INTO package_templates (package_id, template_id) VALUES (?, ?)"
            queryIDStmt := "SELECT id from templates WHERE destination = ? AND path = ?"
            for _, template := range templates {
        Severity: Major
        Found in pkg/package/store/store.go - About 35 mins to fix

          Method packageStore.deepQueryPackage has 5 return statements (exceeds 4 allowed).
          Open

          func (ps packageStore) deepQueryPackage(conditions string, values ...string) (pkg *domain.Package, err error) {
              rows, err := ps.db.Raw(defaultPackageDeepQueryBase+" "+conditions, values).Rows()
              if err != nil {
                  return nil, err
              }
          Severity: Major
          Found in pkg/package/store/store.go - About 35 mins to fix

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

            func storePlugins(tx *gorm.DB, plugins []*domain.Plugin, packageID uint) error {
                var err error
                insertPluginStmt := "INSERT OR IGNORE INTO plugins (created_at, updated_at, path, exec_number, description) VALUES (?, ?, ?, ?, ?)"
                insertAssociationStmt := "INSERT OR IGNORE INTO package_plugins (package_id, plugin_id) VALUES (?, ?)"
                queryIDStmt := "SELECT id from plugins WHERE path = ?"
            Severity: Major
            Found in pkg/package/store/store.go - About 35 mins to fix

              There are no issues that match your filters.

              Category
              Status