From 1ef7a53eb087f63f3d5481ddc554909f3c655479 Mon Sep 17 00:00:00 2001 From: Trey Ivy Date: Mon, 30 Sep 2024 00:21:09 +0000 Subject: [PATCH] lint --- internal/graphql/model/test_result_id.go | 2 +- pkg/processing/save.go | 2 +- pkg/processing/workflow.go | 2 +- .../detectors/action_problem_detector.go | 2 +- .../bazel_invocation_problem_detector.go | 10 ++-- ...gress_bazel_invocation_problem_detector.go | 6 +- ...arget_bazel_invocation_problem_detector.go | 6 +- .../detectors/test_problem_detector.go | 2 +- pkg/summary/detectors/types.go | 8 +-- pkg/summary/summarizer.go | 6 +- pkg/summary/summary.go | 58 +++++++++---------- pkg/testkit/graphql.go | 22 +++---- pkg/uuidgql/uuidgql.go | 4 +- third_party/bazel/generate.go | 2 + 14 files changed, 68 insertions(+), 64 deletions(-) diff --git a/internal/graphql/model/test_result_id.go b/internal/graphql/model/test_result_id.go index 2565109..6629b45 100644 --- a/internal/graphql/model/test_result_id.go +++ b/internal/graphql/model/test_result_id.go @@ -1,6 +1,6 @@ package model -// A Test Result ID struct. +// TestResultID A Test Result ID struct. type TestResultID struct { // Fields need to be exported since GraphQL relay (un)marshaling is using JSON. ProblemID uint64 `json:"problem"` diff --git a/pkg/processing/save.go b/pkg/processing/save.go index 4ee7340..a8bb480 100644 --- a/pkg/processing/save.go +++ b/pkg/processing/save.go @@ -22,7 +22,7 @@ import ( "github.com/buildbarn/bb-portal/pkg/summary/detectors" ) -// The save actor struct with the db client and a blob archiver. +// SaveActor ...SaveActor The save actor struct with the db client and a blob archiver. type SaveActor struct { db *ent.Client blobArchiver BlobMultiArchiver diff --git a/pkg/processing/workflow.go b/pkg/processing/workflow.go index 70c0610..3f04744 100644 --- a/pkg/processing/workflow.go +++ b/pkg/processing/workflow.go @@ -13,7 +13,7 @@ type Workflow struct { SaveActor } -// Worflow constructor +// New Worflow constructor func New(db *ent.Client, blobArchiver BlobMultiArchiver) *Workflow { return &Workflow{ SummarizeActor: SummarizeActor{}, diff --git a/pkg/summary/detectors/action_problem_detector.go b/pkg/summary/detectors/action_problem_detector.go index a4253e3..b308a7e 100644 --- a/pkg/summary/detectors/action_problem_detector.go +++ b/pkg/summary/detectors/action_problem_detector.go @@ -71,7 +71,7 @@ func getOutputsBlobs(outputs []*bes.File) []BlobURI { return blobs } -// ActionProblemDetector +// Problems function func (a ActionProblemDetector) Problems() ([]Problem, error) { if len(a.actionsCompleted) == 0 { return nil, nil diff --git a/pkg/summary/detectors/bazel_invocation_problem_detector.go b/pkg/summary/detectors/bazel_invocation_problem_detector.go index 40fa916..fdb6499 100644 --- a/pkg/summary/detectors/bazel_invocation_problem_detector.go +++ b/pkg/summary/detectors/bazel_invocation_problem_detector.go @@ -2,19 +2,19 @@ package detectors import "github.com/buildbarn/bb-portal/pkg/events" -// BazelInvocationProblemDetector +// BazelInvocationProblemDetector interface type BazelInvocationProblemDetector interface { ProcessBEPEvent(*events.BuildEvent) Problems() ([]Problem, error) } -// ProblemDetector +// ProblemDetector struct type ProblemDetector struct { detectors []BazelInvocationProblemDetector fallbackDetectors []BazelInvocationProblemDetector } -// NewProblemDetector +// NewProblemDetector function func NewProblemDetector() ProblemDetector { return ProblemDetector{ detectors: []BazelInvocationProblemDetector{ @@ -28,7 +28,7 @@ func NewProblemDetector() ProblemDetector { } } -// ProcessBEPEvent +// ProcessBEPEvent function func (p ProblemDetector) ProcessBEPEvent(event *events.BuildEvent) { for _, detector := range p.detectors { detector.ProcessBEPEvent(event) @@ -38,7 +38,7 @@ func (p ProblemDetector) ProcessBEPEvent(event *events.BuildEvent) { } } -// Problems +// Problems function func (p ProblemDetector) Problems() ([]Problem, error) { problems, err := p.detectorsProblems(p.detectors) if err != nil { diff --git a/pkg/summary/detectors/error_progress_bazel_invocation_problem_detector.go b/pkg/summary/detectors/error_progress_bazel_invocation_problem_detector.go index 1e96550..98b93aa 100644 --- a/pkg/summary/detectors/error_progress_bazel_invocation_problem_detector.go +++ b/pkg/summary/detectors/error_progress_bazel_invocation_problem_detector.go @@ -6,10 +6,10 @@ import ( "github.com/buildbarn/bb-portal/pkg/events" ) -// ErrorProgressBazelInvocationProblemDetector +// ErrorProgressBazelInvocationProblemDetector type type ErrorProgressBazelInvocationProblemDetector []*events.BuildEvent -// ProcessBEPEvent +// ProcessBEPEvent function func (e *ErrorProgressBazelInvocationProblemDetector) ProcessBEPEvent(event *events.BuildEvent) { if event == nil || event.GetProgress() == nil { return @@ -20,7 +20,7 @@ func (e *ErrorProgressBazelInvocationProblemDetector) ProcessBEPEvent(event *eve } } -// Problems +// Problems function func (e *ErrorProgressBazelInvocationProblemDetector) Problems() ([]Problem, error) { if len(*e) == 0 { return nil, nil diff --git a/pkg/summary/detectors/failed_target_bazel_invocation_problem_detector.go b/pkg/summary/detectors/failed_target_bazel_invocation_problem_detector.go index feada38..419a1af 100644 --- a/pkg/summary/detectors/failed_target_bazel_invocation_problem_detector.go +++ b/pkg/summary/detectors/failed_target_bazel_invocation_problem_detector.go @@ -5,10 +5,10 @@ import ( "github.com/buildbarn/bb-portal/third_party/bazel/gen/bes" ) -// FailedTargetBazelInvocationProblemDetector +// FailedTargetBazelInvocationProblemDetector map type FailedTargetBazelInvocationProblemDetector map[string]*events.BuildEvent -// ProcessBEPEvent +// ProcessBEPEvent function func (f FailedTargetBazelInvocationProblemDetector) ProcessBEPEvent(event *events.BuildEvent) { if event == nil || !isFailedTarget(event) { return @@ -20,7 +20,7 @@ func (f FailedTargetBazelInvocationProblemDetector) ProcessBEPEvent(event *event f[label] = event } -// Problems +// Problems function func (f FailedTargetBazelInvocationProblemDetector) Problems() ([]Problem, error) { if len(f) == 0 { return nil, nil diff --git a/pkg/summary/detectors/test_problem_detector.go b/pkg/summary/detectors/test_problem_detector.go index ad6ad64..54a82cf 100644 --- a/pkg/summary/detectors/test_problem_detector.go +++ b/pkg/summary/detectors/test_problem_detector.go @@ -5,7 +5,7 @@ import ( "github.com/buildbarn/bb-portal/third_party/bazel/gen/bes" ) -// TestProblemDetector +// TestProblemDetector struct type TestProblemDetector struct { testSummaries map[labelKey]*events.BuildEvent testResults map[labelKey]*events.BuildEvent diff --git a/pkg/summary/detectors/types.go b/pkg/summary/detectors/types.go index 459af02..06d0603 100644 --- a/pkg/summary/detectors/types.go +++ b/pkg/summary/detectors/types.go @@ -7,19 +7,19 @@ import ( // labelKey string type labelKey string -// BazelInvocationProblemType +// BazelInvocationProblemType string type BazelInvocationProblemType string -// BlobURI +// BlobURI string type BlobURI string -// NamedBlob +// NamedBlob struct type NamedBlob struct { BlobURI Name string } -// Problem +// Problem struct type Problem struct { //*ent.BazelInvocationProblem DetectedBlobs []BlobURI diff --git a/pkg/summary/summarizer.go b/pkg/summary/summarizer.go index 697e1c6..a972ba6 100644 --- a/pkg/summary/summarizer.go +++ b/pkg/summary/summarizer.go @@ -80,7 +80,7 @@ func (s Summarizer) summarize(it *events.BuildEventIterator) (*Summary, error) { return s.FinishProcessing() } -// FinishProcessing +// FinishProcessing function func (s Summarizer) FinishProcessing() (*Summary, error) { // If problems are ignored for the exit code, return immediately. if !shouldIgnoreProblems(s.summary.ExitCode) { @@ -95,7 +95,7 @@ func (s Summarizer) FinishProcessing() (*Summary, error) { return s.summary, nil } -// ProcessEvent +// ProcessEvent function func (s Summarizer) ProcessEvent(buildEvent *events.BuildEvent) error { // Let problem detector process every event. s.problemDetector.ProcessBEPEvent(buildEvent) @@ -815,7 +815,7 @@ func envToI(envVars map[string]string, name string) (int, error) { return res, nil } -// ParseEnvVarsFromSectionOptions +// ParseEnvVarsFromSectionOptions function func ParseEnvVarsFromSectionOptions(section *bescore.CommandLineSection, destMap *map[string]string) { if section.GetOptionList() == nil { return diff --git a/pkg/summary/summary.go b/pkg/summary/summary.go index fd8f95d..3213294 100644 --- a/pkg/summary/summary.go +++ b/pkg/summary/summary.go @@ -29,13 +29,13 @@ type MissReason int32 // MissReason enum. const ( - DIFFERENT_ACTION_KEY MissReason = iota + 1 //nolint:revive - DIFFERENT_DEPS //nolint:revive - DIFFERENT_ENVIRONMENT //nolint:revive - DIFFERENT_FILES //nolint:revive - CORRUPTED_CACHE_ENTRY //nolint:revive - NOT_CACHED //nolint:revive - UNCONDITIONAL_EXECUTION //nolint:revive + MissReasonDIFFERENTACTIONKEY MissReason = iota + 1 + MissReasonDIFFERENTDEPS + MissReasonDIFFERENTENVIRONMENT + MissReasonDIFFERENTFILES + MissReasonCORRUPTEDCACHEENTRY + MissReasonNOTCACHED + MissReasonUNCONDITIONALEXECUTION ) // EnumIndex helper method. @@ -62,15 +62,15 @@ type TestStatus int32 // TestStatus enum. const ( - NO_STATUS TestStatus = iota + 1 //nolint - PASSED //nolint - FLAKY //nolint - TIMEOUT //nolint - FAILED //nolint - INCOMPLETE //nolint - REMOTE_FAILURE //nolint - FAILED_TO_BUILD //nolint - TOOL_HALTED_BEFORE_TESTING //nolint + TestStatuNOSTATUS TestStatus = iota + 1 + TestStatuPASSED + TestStatuFLAKY + TestStatuTIMEOUT + TestStatuFAILED + TestStatuINCOMPLETE + TestStatuREMOTEFAILURE + TestStatuFAILEDTOBUILD + TestStatuTOOLHALTEDBEFORETESTING ) // EnumIndex helper method. @@ -105,7 +105,7 @@ const ( ENORMOUS //nolint ) -// Enum helper method. +// EnumIndex Enum helper method. func (r TestSize) EnumIndex() int32 { return int32(r) } @@ -126,18 +126,18 @@ type AbortReason int32 // AbortReason struct set the order explicitly because of ordering mismatches! const ( - Aborted_UNKNOWN AbortReason = 0 //nolint - Aborted_USER_INTERRUPTED AbortReason = 1 //nolint - Aborted_TIME_OUT AbortReason = 2 //nolint - Aborted_REMOTE_ENVIRONMENT_FAILURE AbortReason = 3 //nolint - Aborted_INTERNAL AbortReason = 4 //nolint - Aborted_LOADING_FAILURE AbortReason = 5 //nolint - Aborted_ANALYSIS_FAILURE AbortReason = 6 //nolint - Aborted_SKIPPED AbortReason = 7 //nolint - Aborted_NO_ANALYZE AbortReason = 8 //nolint - Aborted_NO_BUILD AbortReason = 9 //nolint - Aborted_INCOMPLETE AbortReason = 10 //nolint - Aborted_OUT_OF_MEMORY AbortReason = 11 //nolint + AbortedUNKNOWN AbortReason = 0 + AbortedUSERINTERRUPTED AbortReason = 1 + AbortedTIMEOUT AbortReason = 2 + AbortedREMOTEENVIRONMENTFAILURE AbortReason = 3 + AbortedINTERNAL AbortReason = 4 + AbortedLOADINGFAILURE AbortReason = 5 + AbortedANALYSISFAILURE AbortReason = 6 + AbortedSKIPPED AbortReason = 7 + AbortedNOANALYZE AbortReason = 8 + AbortedNOBUILD AbortReason = 9 + AbortedINCOMPLETE AbortReason = 10 + AbortedOUTOFMEMORY AbortReason = 11 ) // EnumIndex helper method. diff --git a/pkg/testkit/graphql.go b/pkg/testkit/graphql.go index 4da0142..1b9755e 100644 --- a/pkg/testkit/graphql.go +++ b/pkg/testkit/graphql.go @@ -25,12 +25,12 @@ type registryEntry struct { used bool } -// QueryRegistry +// QueryRegistry struct type QueryRegistry struct { entries map[string]*registryEntry } -// LoadQueryRegistry +// LoadQueryRegistry function func LoadQueryRegistry(t *testing.T, queryDir, consumerContractFile string) *QueryRegistry { reg := QueryRegistry{entries: make(map[string]*registryEntry)} @@ -60,7 +60,7 @@ func LoadQueryRegistry(t *testing.T, queryDir, consumerContractFile string) *Que return ® } -// Register +// Register function func (reg QueryRegistry) Register(opName string, document Document) error { _, exists := reg.entries[opName] if exists { @@ -72,13 +72,13 @@ func (reg QueryRegistry) Register(opName string, document Document) error { return nil } -// NewRequest +// NewRequest fuction func (reg QueryRegistry) NewRequest(opName string) *graphql.Request { document := reg.MustGet(opName) return graphql.NewRequest(string(document)) } -// MustGet +// MustGet function func (reg QueryRegistry) MustGet(opName string) Document { if entry, exists := reg.entries[opName]; exists { entry.used = true @@ -87,7 +87,7 @@ func (reg QueryRegistry) MustGet(opName string) Document { panic(fmt.Sprintf("operation %s is not regisitered", opName)) } -// UnusedOperations +// UnusedOperations function func (reg QueryRegistry) UnusedOperations() []string { unused := []string{} for name, entry := range reg.entries { @@ -99,19 +99,21 @@ func (reg QueryRegistry) UnusedOperations() []string { return unused } -// ConsumerContract +// ConsumerContract struct type ConsumerContract struct { GeneratedAt time.Time `yaml:"generatedAt"` Operations map[string]Operation `yaml:"operations"` } -// Document and Variables types type ( - Document string + // Document and Variables types + Document string + + // Variables struct Variables map[string]interface{} ) -// Operation +// Operation struct type Operation struct { Document Document `yaml:"document"` Signature string `yaml:"signature"` diff --git a/pkg/uuidgql/uuidgql.go b/pkg/uuidgql/uuidgql.go index 03d1177..28747e7 100644 --- a/pkg/uuidgql/uuidgql.go +++ b/pkg/uuidgql/uuidgql.go @@ -13,14 +13,14 @@ import ( // errExpectedString var errExpectedString = errors.New("expected string") -// MarshalUUID +// MarshalUUID gets the id func MarshalUUID(u uuid.UUID) graphql.Marshaler { return graphql.WriterFunc(func(w io.Writer) { _, _ = io.WriteString(w, strconv.Quote(u.String())) }) } -// UnmarshalUUID +// UnmarshalUUID unmarsalls the id func UnmarshalUUID(v interface{}) (u uuid.UUID, err error) { s, ok := v.(string) if !ok { diff --git a/third_party/bazel/generate.go b/third_party/bazel/generate.go index c6e8943..bda6ca0 100644 --- a/third_party/bazel/generate.go +++ b/third_party/bazel/generate.go @@ -1,2 +1,4 @@ +// Package bazel package +// //go:generate scripts/generate-via-bazel.sh package bazel