Added new checks (#2)
* added gocyclo-check * Added new tests to drone * Added new checks to makefile
This commit is contained in:
parent
b912ff4176
commit
e724aeb206
9 changed files with 34 additions and 8 deletions
|
@ -21,6 +21,8 @@ pipeline:
|
||||||
- make lint
|
- make lint
|
||||||
- make fmt-check
|
- make fmt-check
|
||||||
- make swagger-check
|
- make swagger-check
|
||||||
|
- make ineffassign-check
|
||||||
|
- make misspell-check
|
||||||
- make build
|
- make build
|
||||||
when:
|
when:
|
||||||
event: [ push, tag, pull_request ]
|
event: [ push, tag, pull_request ]
|
||||||
|
|
21
Makefile
21
Makefile
|
@ -170,3 +170,24 @@ swagger-validate:
|
||||||
go get -u github.com/go-swagger/go-swagger/cmd/swagger; \
|
go get -u github.com/go-swagger/go-swagger/cmd/swagger; \
|
||||||
fi
|
fi
|
||||||
swagger validate ./public/swagger/swagger.v1.json
|
swagger validate ./public/swagger/swagger.v1.json
|
||||||
|
|
||||||
|
.PHONY: misspell-check
|
||||||
|
misspell-check:
|
||||||
|
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||||
|
go get -u github.com/client9/misspell/cmd/misspell; \
|
||||||
|
fi
|
||||||
|
for S in $(GOFILES); do misspell -error $$S || exit 1; done;
|
||||||
|
|
||||||
|
.PHONY: ineffassign-check
|
||||||
|
ineffassign-check:
|
||||||
|
@hash ineffassign > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||||
|
go get -u github.com/gordonklaus/ineffassign; \
|
||||||
|
fi
|
||||||
|
for S in $(GOFILES); do ineffassign $$S || exit 1; done;
|
||||||
|
|
||||||
|
.PHONY: gocyclo-check
|
||||||
|
gocyclo-check:
|
||||||
|
@hash gocyclo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||||
|
go get github.com/fzipp/gocyclo; \
|
||||||
|
fi
|
||||||
|
for S in $(GOFILES); do gocyclo -over 14 $$S || exit 1; done;
|
|
@ -348,7 +348,7 @@ func IsErrNamespaceNameCannotBeEmpty(err error) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (err ErrNamespaceNameCannotBeEmpty) Error() string {
|
func (err ErrNamespaceNameCannotBeEmpty) Error() string {
|
||||||
return fmt.Sprintf("Namespace name cannot be emtpy [NamespaceID: %d, UserID: %d]", err.NamespaceID, err.UserID)
|
return fmt.Sprintf("Namespace name cannot be empty [NamespaceID: %d, UserID: %d]", err.NamespaceID, err.UserID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrNamespaceOwnerCannotBeEmpty represents an error, where a namespace owner is empty.
|
// ErrNamespaceOwnerCannotBeEmpty represents an error, where a namespace owner is empty.
|
||||||
|
@ -364,7 +364,7 @@ func IsErrNamespaceOwnerCannotBeEmpty(err error) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (err ErrNamespaceOwnerCannotBeEmpty) Error() string {
|
func (err ErrNamespaceOwnerCannotBeEmpty) Error() string {
|
||||||
return fmt.Sprintf("Namespace owner cannot be emtpy [NamespaceID: %d, UserID: %d]", err.NamespaceID, err.UserID)
|
return fmt.Sprintf("Namespace owner cannot be empty [NamespaceID: %d, UserID: %d]", err.NamespaceID, err.UserID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrNeedToBeNamespaceAdmin represents an error, where the user is not the admin of that namespace (used i.e. when deleting a namespace)
|
// ErrNeedToBeNamespaceAdmin represents an error, where the user is not the admin of that namespace (used i.e. when deleting a namespace)
|
||||||
|
|
|
@ -39,7 +39,7 @@ func createTestEngine(fixturesDir string) error {
|
||||||
return fmt.Errorf("sync database struct error: %v", err)
|
return fmt.Errorf("sync database struct error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show SQL-Queries if nessecary
|
// Show SQL-Queries if necessary
|
||||||
if os.Getenv("UNIT_TESTS_VERBOSE") == "1" {
|
if os.Getenv("UNIT_TESTS_VERBOSE") == "1" {
|
||||||
x.ShowSQL(true)
|
x.ShowSQL(true)
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ func GetListsByNamespaceID(c echo.Context) error {
|
||||||
if models.IsErrUserDoesNotHaveAccessToNamespace(err) {
|
if models.IsErrUserDoesNotHaveAccessToNamespace(err) {
|
||||||
return c.JSON(http.StatusForbidden, models.Message{"You don't have access to this namespace."})
|
return c.JSON(http.StatusForbidden, models.Message{"You don't have access to this namespace."})
|
||||||
}
|
}
|
||||||
return c.JSON(http.StatusInternalServerError, models.Message{"An error occured."})
|
return c.JSON(http.StatusInternalServerError, models.Message{"An error occurred."})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the lists
|
// Get the lists
|
||||||
|
@ -48,7 +48,7 @@ func GetListsByNamespaceID(c echo.Context) error {
|
||||||
if models.IsErrNamespaceDoesNotExist(err) {
|
if models.IsErrNamespaceDoesNotExist(err) {
|
||||||
return c.JSON(http.StatusNotFound, models.Message{"Namespace not found."})
|
return c.JSON(http.StatusNotFound, models.Message{"Namespace not found."})
|
||||||
}
|
}
|
||||||
return c.JSON(http.StatusInternalServerError, models.Message{"An error occured."})
|
return c.JSON(http.StatusInternalServerError, models.Message{"An error occurred."})
|
||||||
}
|
}
|
||||||
return c.JSON(http.StatusOK, lists)
|
return c.JSON(http.StatusOK, lists)
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ func UserList(c echo.Context) error {
|
||||||
users, err := models.ListUsers(s)
|
users, err := models.ListUsers(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
models.Log.Error(err.Error())
|
models.Log.Error(err.Error())
|
||||||
return echo.NewHTTPError(http.StatusInternalServerError, "An error occured.")
|
return echo.NewHTTPError(http.StatusInternalServerError, "An error occurred.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obfuscate the mailadresses
|
// Obfuscate the mailadresses
|
||||||
|
|
|
@ -30,6 +30,9 @@ func UserChangePassword(c echo.Context) error {
|
||||||
|
|
||||||
// Check if the user is itself
|
// Check if the user is itself
|
||||||
userJWTinfo, err := models.GetCurrentUser(c)
|
userJWTinfo, err := models.GetCurrentUser(c)
|
||||||
|
if err != nil {
|
||||||
|
return c.JSON(http.StatusInternalServerError, models.Message{"Error getting current user."})
|
||||||
|
}
|
||||||
|
|
||||||
if userJWTinfo.ID != userID {
|
if userJWTinfo.ID != userID {
|
||||||
return echo.ErrUnauthorized
|
return echo.ErrUnauthorized
|
||||||
|
|
|
@ -30,7 +30,7 @@ func (c *WebHandler) ReadAllWeb(ctx echo.Context) error {
|
||||||
return echo.NewHTTPError(http.StatusNotFound, "This namespace does not exist.")
|
return echo.NewHTTPError(http.StatusNotFound, "This namespace does not exist.")
|
||||||
}
|
}
|
||||||
|
|
||||||
return echo.NewHTTPError(http.StatusInternalServerError, "An error occured.")
|
return echo.NewHTTPError(http.StatusInternalServerError, "An error occurred.")
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx.JSON(http.StatusOK, lists)
|
return ctx.JSON(http.StatusOK, lists)
|
||||||
|
|
|
@ -31,7 +31,7 @@ func (c *WebHandler) ReadOneWeb(ctx echo.Context) error {
|
||||||
return echo.NewHTTPError(http.StatusNotFound)
|
return echo.NewHTTPError(http.StatusNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
return echo.NewHTTPError(http.StatusInternalServerError, "An error occured.")
|
return echo.NewHTTPError(http.StatusInternalServerError, "An error occurred.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check rights
|
// Check rights
|
||||||
|
|
Loading…
Add table
Reference in a new issue