Skip to content

Commit

Permalink
Fix lint issues (#114)
Browse files Browse the repository at this point in the history
* Add lint config

* Fix lint issues
  • Loading branch information
marcobebway authored Feb 2, 2024
1 parent 3c99afc commit 7f858d0
Show file tree
Hide file tree
Showing 16 changed files with 156 additions and 124 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ Dockerfile.cross
*~

vendor
.golangci.yaml
lint-report.json
33 changes: 33 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,36 @@ $(CONTROLLER_GEN): $(LOCALBIN)
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

# Lint issue category
CATEGORY = "default"

.PHONY: lint
lint: ## Check lint issues using `golangci-lint`
golangci-lint run --timeout 5m --config=./.golangci.yaml

.PHONY: lint-compact
lint-compact: ## Check lint issues using `golangci-lint` in compact result format
golangci-lint run --timeout 5m --config=./.golangci.yaml --print-issued-lines=false

.PHONY: lint-fix
lint-fix: ## Check and fix lint issues using `golangci-lint`
golangci-lint run --fix --timeout 5m --config=./.golangci.yaml

.PHONY: lint-report
lint-report: ## Check lint issues using `golangci-lint` then export them to a file, then print the list of linters used
golangci-lint run --timeout 5m --config=./.golangci.yaml --issues-exit-code 0 --out-format json > ./lint-report.json

.PHONY: lint-report-issue-category
lint-report-issue-category: ## Get lint issues categories
make lint-report-clean
make lint-report
cat ./lint-report.json | jq '.Issues[].FromLinter' | jq -s 'map({(.):1})|add|keys_unsorted'

.PHONY: lint-report-get-category
lint-report-get-category: ## Get lint issues by category
cat ./lint-report.json | jq --arg CATEGORY $$CATEGORY '.Issues[] | select(.FromLinter==$$CATEGORY)'

.PHONY: lint-report-clean
lint-report-clean: ## Clean lint report
rm -f ./lint-report.json
8 changes: 4 additions & 4 deletions api/v1alpha1/eventingauth_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ const (
StateNotReady State = "NotReady"
)

// EventingAuthSpec defines the desired state of EventingAuth
// EventingAuthSpec defines the desired state of EventingAuth.
type EventingAuthSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
}

// EventingAuthStatus defines the observed state of EventingAuth
// EventingAuthStatus defines the observed state of EventingAuth.
type EventingAuthStatus struct {
// State signifies current state of CustomObject. Value
// can be one of ("Ready", "NotReady").
Expand Down Expand Up @@ -69,7 +69,7 @@ type AuthSecret struct {
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.state"

// EventingAuth is the Schema for the eventingauths API
// EventingAuth is the Schema for the eventingauths API.
type EventingAuth struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -80,7 +80,7 @@ type EventingAuth struct {

//+kubebuilder:object:root=true

// EventingAuthList contains a list of EventingAuth
// EventingAuthList contains a list of EventingAuth.
type EventingAuthList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
)

var (
// GroupVersion is group version used to register these objects
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "operator.kyma-project.io", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
Expand Down
Loading

0 comments on commit 7f858d0

Please sign in to comment.