Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Run fieldalignment on ./checker, ./checks and ./finding #3569

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions checker/check_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,13 @@ var errSuccessTotal = errors.New("unexpected number of success is higher than to
//
//nolint:govet
type CheckResult struct {
Name string
Version int
Error error
Score int
Name string
Reason string
Details []CheckDetail
// Structured results.
Rules []string // TODO(X): add support.
Rules []string
Version int
Score int
}

// CheckDetail contains information for each detail.
Expand All @@ -80,17 +79,14 @@ type CheckDetail struct {
//
//nolint:govet
type LogMessage struct {
// Structured results.
Finding *finding.Finding

// Non-structured results.
Text string // A short string explaining why the detail was recorded/logged.
Path string // Fullpath to the file.
Type finding.FileType // Type of file.
Offset uint // Offset in the file of Path (line for source/text files).
EndOffset uint // End of offset in the file, e.g. if the command spans multiple lines.
Snippet string // Snippet of code
Remediation *rule.Remediation // Remediation information, if any.
Finding *finding.Finding
Remediation *rule.Remediation
Text string
Path string
Snippet string
Type finding.FileType
Offset uint
EndOffset uint
}

// ProportionalScoreWeighted is a structure that contains
Expand Down
14 changes: 7 additions & 7 deletions checker/check_result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ func TestAggregateScoresWithWeight(t *testing.T) {
type args struct {
scores map[int]int
}
tests := []struct { //nolint:govet
name string
tests := []struct {
args args
name string
want int
}{
{
Expand Down Expand Up @@ -412,10 +412,10 @@ func TestNormalizeReason(t *testing.T) {
reason string
score int
}
tests := []struct { //nolint:govet
tests := []struct {
name string
args args
want string
args args
}{
{
name: "empty",
Expand Down Expand Up @@ -505,7 +505,7 @@ func TestCreateProportionalScoreResult(t *testing.T) {
b int
t int
}
tests := []struct { //nolint:govet
tests := []struct {
name string
args args
want CheckResult
Expand Down Expand Up @@ -701,9 +701,9 @@ func TestCreateInconclusiveResult(t *testing.T) {

func TestCreateRuntimeErrorResult(t *testing.T) {
t.Parallel()
type args struct { //nolint:govet
name string
type args struct {
e error
name string
}
tests := []struct {
name string
Expand Down
8 changes: 4 additions & 4 deletions checker/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ import (
// nolint:paralleltest
// because we are using t.Setenv.
func TestGetClients(t *testing.T) { //nolint:gocognit
type args struct { //nolint:govet
type args struct {
ctx context.Context
logger *log.Logger
repoURI string
localURI string
logger *log.Logger
}
tests := []struct { //nolint:govet
name string
tests := []struct {
args args
name string
shouldOSSFuzzBeNil bool
shouldRepoClientBeNil bool
shouldVulnClientBeNil bool
Expand Down
20 changes: 10 additions & 10 deletions checker/raw_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,25 @@ import (
// is applied.
// nolint
type RawResults struct {
BinaryArtifactResults BinaryArtifactData
Metadata MetadataData
BranchProtectionResults BranchProtectionsData
CIIBestPracticesResults CIIBestPracticesData
CITestResults CITestData
FuzzingResults FuzzingData
SignedReleasesResults SignedReleasesData
CodeReviewResults CodeReviewData
ContributorsResults ContributorsData
DangerousWorkflowResults DangerousWorkflowData
WebhookResults WebhooksData
DependencyUpdateToolResults DependencyUpdateToolData
FuzzingResults FuzzingData
BinaryArtifactResults BinaryArtifactData
LicenseResults LicenseData
MaintainedResults MaintainedData
Metadata MetadataData
VulnerabilitiesResults VulnerabilitiesData
CITestResults CITestData
PackagingResults PackagingData
PinningDependenciesResults PinningDependenciesData
SecurityPolicyResults SecurityPolicyData
SignedReleasesResults SignedReleasesData
MaintainedResults MaintainedData
TokenPermissionsResults TokenPermissionsData
VulnerabilitiesResults VulnerabilitiesData
WebhookResults WebhooksData
DangerousWorkflowResults DangerousWorkflowData
CIIBestPracticesResults CIIBestPracticesData
Comment on lines +28 to +46
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this reverse #3540 ?

Can we talk about what you're seeing with make check-linter?

}

type MetadataData struct {
Expand Down
4 changes: 2 additions & 2 deletions checks/all_checks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ func Test_registerCheck(t *testing.T) {
t.Parallel()
//nolint
type args struct {
name string
fn checker.CheckFn
name string
}
//nolint
tests := []struct {
name string
args args
name string
wanterr bool
}{
{
Expand Down
6 changes: 3 additions & 3 deletions checks/branch_protection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ func TestReleaseAndDevBranchProtected(t *testing.T) {
//nolint
tests := []struct {
name string
expected scut.TestReturn
branches []*clients.BranchRef
defaultBranch string
branches []*clients.BranchRef
releases []string
nonadmin bool
repoFiles []string
expected scut.TestReturn
nonadmin bool
}{
{
name: "Nil release and main branch names",
Expand Down
6 changes: 3 additions & 3 deletions checks/dependency_update_tool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ func TestDependencyUpdateTool(t *testing.T) {
//nolint
tests := []struct {
name string
wantErr bool
want checker.CheckResult
SearchCommits []clients.Commit
CallSearchCommits int
files []string
want checker.CheckResult
expected scut.TestReturn
CallSearchCommits int
wantErr bool
}{
{
name: "dependency yml",
Expand Down
2 changes: 1 addition & 1 deletion checks/evaluation/binary_artifacts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ func TestBinaryArtifacts(t *testing.T) {
t.Parallel()
//nolint
type args struct {
name string
dl checker.DetailLogger
r *checker.BinaryArtifactData
name string
}
tests := []struct {
name string
Expand Down
22 changes: 11 additions & 11 deletions checks/evaluation/ci_tests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,11 @@ func Test_prHasSuccessfulCheck(t *testing.T) {

func Test_prHasSuccessStatus(t *testing.T) {
t.Parallel()
type args struct { //nolint:govet
r checker.RevisionCIInfo
type args struct {
dl checker.DetailLogger
r checker.RevisionCIInfo
}
tests := []struct { //nolint:govet
tests := []struct {
name string
args args
want bool
Expand Down Expand Up @@ -277,11 +277,11 @@ func Test_prHasSuccessStatus(t *testing.T) {

func Test_prHasSuccessfulCheckAdditional(t *testing.T) {
t.Parallel()
type args struct { //nolint:govet
r checker.RevisionCIInfo
type args struct {
dl checker.DetailLogger
r checker.RevisionCIInfo
}
tests := []struct { //nolint:govet
tests := []struct {
name string
args args
want bool
Expand Down Expand Up @@ -369,14 +369,14 @@ func Test_prHasSuccessfulCheckAdditional(t *testing.T) {

func TestCITests(t *testing.T) {
t.Parallel()
type args struct { //nolint:govet
in0 string
c *checker.CITestData
type args struct {
dl checker.DetailLogger
c *checker.CITestData
in0 string
}
tests := []struct { //nolint:govet
name string
tests := []struct {
args args
name string
want int
}{
{
Expand Down
2 changes: 1 addition & 1 deletion checks/evaluation/code_review_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ func TestCodeReview(t *testing.T) {

//nolint:govet // ignore since this is a test.
tests := []struct {
rawData *checker.CodeReviewData
name string
expected scut.TestReturn
rawData *checker.CodeReviewData
}{
{
name: "NullRawData",
Expand Down
4 changes: 2 additions & 2 deletions checks/evaluation/dangerous_workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (

func TestDangerousWorkflow(t *testing.T) {
t.Parallel()
type args struct { //nolint:govet
name string
type args struct {
dl checker.DetailLogger
r *checker.DangerousWorkflowData
name string
}
tests := []struct {
name string
Expand Down
8 changes: 4 additions & 4 deletions checks/evaluation/license_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ func Test_scoreLicenseCriteria(t *testing.T) {
f *checker.LicenseFile
dl checker.DetailLogger
}
tests := []struct { //nolint:govet
name string
tests := []struct {
args args
name string
want int
}{
{
Expand Down Expand Up @@ -97,10 +97,10 @@ func Test_scoreLicenseCriteria(t *testing.T) {

func TestLicense(t *testing.T) {
t.Parallel()
type args struct { //nolint:govet
name string
type args struct {
dl checker.DetailLogger
r *checker.LicenseData
name string
}
tests := []struct {
name string
Expand Down
8 changes: 4 additions & 4 deletions checks/evaluation/maintained_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ func Test_hasActivityByCollaboratorOrHigher(t *testing.T) {
issue *clients.Issue
threshold time.Time
}
tests := []struct { //nolint:govet
name string
tests := []struct {
args args
name string
want bool
}{
{
Expand Down Expand Up @@ -98,10 +98,10 @@ func TestMaintained(t *testing.T) {
twentyDaysAgo := time.Now().AddDate(0 /*years*/, 0 /*months*/, -20 /*days*/)
collab := clients.RepoAssociationCollaborator
t.Parallel()
type args struct { //nolint:govet
name string
type args struct {
dl checker.DetailLogger
r *checker.MaintainedData
name string
}
tests := []struct {
name string
Expand Down
6 changes: 3 additions & 3 deletions checks/evaluation/packaging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
func Test_createLogMessage(t *testing.T) {
msg := "msg"
t.Parallel()
tests := []struct { //nolint:govet
tests := []struct {
name string
args checker.Package
want checker.LogMessage
Expand Down Expand Up @@ -103,10 +103,10 @@ func Test_createLogMessage(t *testing.T) {

func TestPackaging(t *testing.T) {
t.Parallel()
type args struct { //nolint:govet
name string
type args struct {
dl checker.DetailLogger
r *checker.PackagingData
name string
}
tests := []struct {
name string
Expand Down
10 changes: 5 additions & 5 deletions checks/evaluation/pinned_dependencies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func Test_createScoreForGitHubActionsWorkflow(t *testing.T) {
//nolint
tests := []struct {
name string
r worklowPinningResult
scores []checker.ProportionalScoreWeighted
r worklowPinningResult
}{
{
name: "GitHub-owned and Third-Party actions pinned",
Expand Down Expand Up @@ -819,10 +819,10 @@ func Test_PinningDependencies(t *testing.T) {

func Test_generateOwnerToDisplay(t *testing.T) {
t.Parallel()
tests := []struct { //nolint:govet
tests := []struct {
name string
gitHubOwned bool
want string
gitHubOwned bool
}{
{
name: "returns GitHub if gitHubOwned is true",
Expand Down Expand Up @@ -1009,10 +1009,10 @@ func TestUpdatePinningResults(t *testing.T) {
w *worklowPinningResult
pr map[checker.DependencyUseType]pinnedResult
}
tests := []struct { //nolint:govet
name string
tests := []struct {
args args
want want
name string
}{
{
name: "add pinned GitHub-owned action",
Expand Down
Loading
Loading