Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Trey Ivy committed Sep 30, 2024
1 parent 71aab19 commit 1ef7a53
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 64 deletions.
2 changes: 1 addition & 1 deletion internal/graphql/model/test_result_id.go
Original file line number Diff line number Diff line change
@@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/processing/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/processing/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
Expand Down
2 changes: 1 addition & 1 deletion pkg/summary/detectors/action_problem_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions pkg/summary/detectors/bazel_invocation_problem_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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)
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/summary/detectors/test_problem_detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pkg/summary/detectors/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions pkg/summary/summarizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
58 changes: 29 additions & 29 deletions pkg/summary/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -105,7 +105,7 @@ const (
ENORMOUS //nolint
)

// Enum helper method.
// EnumIndex Enum helper method.
func (r TestSize) EnumIndex() int32 {
return int32(r)
}
Expand All @@ -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.
Expand Down
22 changes: 12 additions & 10 deletions pkg/testkit/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)}

Expand Down Expand Up @@ -60,7 +60,7 @@ func LoadQueryRegistry(t *testing.T, queryDir, consumerContractFile string) *Que
return &reg
}

// Register
// Register function
func (reg QueryRegistry) Register(opName string, document Document) error {
_, exists := reg.entries[opName]
if exists {
Expand All @@ -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
Expand All @@ -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 {
Expand All @@ -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"`
Expand Down
4 changes: 2 additions & 2 deletions pkg/uuidgql/uuidgql.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions third_party/bazel/generate.go
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
// Package bazel package
//
//go:generate scripts/generate-via-bazel.sh
package bazel

0 comments on commit 1ef7a53

Please sign in to comment.