diff --git a/Makefile b/Makefile index 8eac8ef12..61ac46428 100644 --- a/Makefile +++ b/Makefile @@ -376,7 +376,7 @@ gosec: $(GOPATH)/bin/gosec -fmt=json -out=harbor_gas_output.json -quiet ./... | true ; \ fi -go_check: misspell golint govet gofmt +go_check: misspell golint govet gofmt commentfmt gofmt: @echo checking gofmt... @@ -387,6 +387,16 @@ gofmt: exit 1; \ fi +commentfmt: + @echo checking comment format... + @res=$$(find . -type d \( -path ./src/vendor -o -path ./tests \) -prune -o -name '*.go' -print | xargs egrep '(^|\s)\/\/(\S)'); \ + if [ -n "$${res}" ]; then \ + echo checking comment format fail.. ; \ + echo missing whitespace between // and comment body;\ + echo "$${res}"; \ + exit 1; \ + fi + misspell: @echo checking misspell... @find . -type d \( -path ./src/vendor -o -path ./tests \) -prune -o -name '*.go' -print | xargs misspell -error diff --git a/src/chartserver/handler_repo.go b/src/chartserver/handler_repo.go index db3fe0c21..01f3b6f77 100644 --- a/src/chartserver/handler_repo.go +++ b/src/chartserver/handler_repo.go @@ -15,7 +15,7 @@ import ( const ( maxWorkers = 10 - //Keep consistent with 'helm search' command + // Keep consistent with 'helm search' command searchMaxScore = 25 ) @@ -102,15 +102,15 @@ LOOP: waitGroup.Add(1) go func(ns string) { defer func() { - waitGroup.Done() //done - //Return the worker back to the pool + waitGroup.Done() // done + // Return the worker back to the pool workerPool <- struct{}{} }() indexFile, err := c.getIndexYamlWithNS(ns) if err != nil { if len(errorChan) == 0 { - //Only need one error as failure signal + // Only need one error as failure signal errorChan <- err } return diff --git a/src/core/api/harborapi_test.go b/src/core/api/harborapi_test.go index f690c7dc7..1a9efdef3 100644 --- a/src/core/api/harborapi_test.go +++ b/src/core/api/harborapi_test.go @@ -299,13 +299,13 @@ func (a testapi) LogGet(user usrInfo) (int, []apilib.AccessLog, error) { return code, successPayload, err } -// //Delete a repository or a tag in a repository. -// //Delete a repository or a tag in a repository. -// //This endpoint let user delete repositories and tags with repo name and tag.\n -// //@param repoName The name of repository which will be deleted. -// //@param tag Tag of a repository. -// //@return void -// //func (a testapi) RepositoriesDelete(prjUsr UsrInfo, repoName string, tag string) (int, error) { +// // Delete a repository or a tag in a repository. +// // Delete a repository or a tag in a repository. +// // This endpoint let user delete repositories and tags with repo name and tag.\n +// // @param repoName The name of repository which will be deleted. +// // @param tag Tag of a repository. +// // @return void +// // func (a testapi) RepositoriesDelete(prjUsr UsrInfo, repoName string, tag string) (int, error) { // func (a testapi) RepositoriesDelete(prjUsr UsrInfo, repoName string, tag string) (int, error) { // _sling := sling.New().Delete(a.basePath) diff --git a/src/core/api/search_test.go b/src/core/api/search_test.go index ac3926e33..a838a149f 100644 --- a/src/core/api/search_test.go +++ b/src/core/api/search_test.go @@ -31,7 +31,7 @@ import ( func TestSearch(t *testing.T) { fmt.Println("Testing Search(SearchGet) API") - //Use mock chart search handler + // Use mock chart search handler searchHandler = func(string, []string) ([]*search.Result, error) { results := []*search.Result{} results = append(results, &search.Result{ @@ -178,7 +178,7 @@ func TestSearch(t *testing.T) { _, exist = repositories["search-2/hello-world"] assert.True(t, exist) - //Search chart + // Search chart err = handleAndParse(&testingRequest{ method: http.MethodGet, url: "/api/search", @@ -193,6 +193,6 @@ func TestSearch(t *testing.T) { require.Equal(t, 1, len(result.Chart)) require.Equal(t, "library/harbor", result.Chart[0].Name) - //Restore chart search handler + // Restore chart search handler searchHandler = nil } diff --git a/src/portal/lib/src/config/registry-config.component.ts b/src/portal/lib/src/config/registry-config.component.ts index fcf6ed468..f7f8acd1b 100644 --- a/src/portal/lib/src/config/registry-config.component.ts +++ b/src/portal/lib/src/config/registry-config.component.ts @@ -13,7 +13,7 @@ import { clone } from '../utils'; import { ErrorHandler } from '../error-handler/index'; -import { SystemSettingsComponent, VulnerabilityConfigComponent } from './index'; +import { SystemSettingsComponent, VulnerabilityConfigComponent} from './index'; import { Configuration } from './config'; @Component({ diff --git a/src/portal/lib/src/config/system/system-settings.component.ts b/src/portal/lib/src/config/system/system-settings.component.ts index 29524fa09..4ec95e194 100644 --- a/src/portal/lib/src/config/system/system-settings.component.ts +++ b/src/portal/lib/src/config/system/system-settings.component.ts @@ -1,6 +1,5 @@ import { Component, Input, Output, EventEmitter, ViewChild, Inject } from '@angular/core'; import { NgForm } from '@angular/forms'; - import { Configuration } from '../config'; import { SERVICE_CONFIG, IServiceConfig } from '../../service.config'; diff --git a/src/portal/lib/src/create-edit-label/create-edit-label.component.html b/src/portal/lib/src/create-edit-label/create-edit-label.component.html index 7596d4a64..ab1f83b9d 100644 --- a/src/portal/lib/src/create-edit-label/create-edit-label.component.html +++ b/src/portal/lib/src/create-edit-label/create-edit-label.component.html @@ -14,10 +14,8 @@