Skip to content

Commit

Permalink
🌱 Fixed field alignment (#3799)
Browse files Browse the repository at this point in the history
- Fixed field alignment

Signed-off-by: naveensrinivasan <[email protected]>
  • Loading branch information
naveensrinivasan authored Jan 17, 2024
1 parent 4a2dfa9 commit f1d7a62
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 42 deletions.
18 changes: 6 additions & 12 deletions finding/finding.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@ const (
)

// Location represents the location of a finding.
//
//nolint:govet
type Location struct {
Type FileType `json:"type"`
Path string `json:"path"`
LineStart *uint `json:"lineStart,omitempty"`
LineEnd *uint `json:"lineEnd,omitempty"`
Snippet *string `json:"snippet,omitempty"`
Path string `json:"path"`
Type FileType `json:"type"`
}

// Outcome is the result of a finding.
Expand Down Expand Up @@ -96,23 +94,19 @@ const (
)

// Finding represents a finding.
//
//nolint:govet
type Finding struct {
Probe string `json:"probe"`
Outcome Outcome `json:"outcome"`
Message string `json:"message"`
Location *Location `json:"location,omitempty"`
Remediation *probe.Remediation `json:"remediation,omitempty"`
Values map[string]int `json:"values,omitempty"`
Probe string `json:"probe"`
Message string `json:"message"`
Outcome Outcome `json:"outcome"`
}

// AnonymousFinding is a finding without a corerpsonding probe ID.
type AnonymousFinding struct {
Finding
// Remove the probe ID from
// the structure until the probes are GA.
Probe string `json:"probe,omitempty"`
Finding
}

var errInvalid = errors.New("invalid")
Expand Down
13 changes: 6 additions & 7 deletions finding/finding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,14 @@ func Test_FromBytes(t *testing.T) {
positiveOutcome := OutcomePositive
negativeOutcome := OutcomeNegative
t.Parallel()
//nolint:govet
tests := []struct {
name string
id string
path string
outcome *Outcome
err error
outcome *Outcome
metadata map[string]string
finding *Finding
name string
id string
path string
}{
{
name: "effort low",
Expand Down Expand Up @@ -205,10 +204,10 @@ func TestOutcome_UnmarshalYAML(t *testing.T) {
type args struct {
n *yaml.Node
}
tests := []struct { //nolint:govet
tests := []struct {
args args
name string
wantOutcome Outcome
args args
wantErr bool
}{
{
Expand Down
9 changes: 4 additions & 5 deletions remediation/remediations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,10 @@ func (s stubDigester) Digest(name string) (string, error) {
func TestCreateDockerfilePinningRemediation(t *testing.T) {
t.Parallel()

//nolint:govet
tests := []struct {
name string
dep checker.Dependency
expected *rule.Remediation
dep checker.Dependency
name string
}{
{
name: "no depdendency",
Expand Down Expand Up @@ -143,12 +142,12 @@ func TestCreateDockerfilePinningRemediation(t *testing.T) {
func TestCreateWorkflowPinningRemediation(t *testing.T) {
t.Parallel()

tests := []struct { //nolint:govet
tests := []struct {
expected *rule.Remediation
name string
branch string
repo string
filepath string
expected *rule.Remediation
}{
{
name: "valid input",
Expand Down
6 changes: 2 additions & 4 deletions rule/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,13 @@ type jsonRemediation struct {
Effort RemediationEffort `yaml:"effort"`
}

//nolint:govet
type jsonRule struct {
Short string `yaml:"short"`
Desc string `yaml:"desc"`
Motivation string `yaml:"motivation"`
Implementation string `yaml:"implementation"`
Risk Risk `yaml:"risk"`
Remediation jsonRemediation `yaml:"remediation"`
Risk Risk `yaml:"risk"`
}

// Risk indicates a risk.
Expand All @@ -81,14 +80,13 @@ const (
RiskCritical
)

//nolint:govet
type Rule struct {
Remediation *Remediation
Name string
Short string
Desc string
Motivation string
Risk Risk
Remediation *Remediation
}

var errInvalid = errors.New("invalid")
Expand Down
27 changes: 13 additions & 14 deletions rule/rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ var testfs embed.FS

func Test_New(t *testing.T) {
t.Parallel()
//nolint:govet
tests := []struct {
name string
id string
err error
rule *Rule
name string
id string
}{
{
name: "all fields set",
Expand Down Expand Up @@ -131,10 +130,10 @@ func TestRisk_GreaterThan(t *testing.T) {
func TestRisk_String(t *testing.T) {
t.Parallel()

tests := []struct { //nolint:govet
tests := []struct {
name string
r Risk
want string
r Risk
}{
{
name: "RiskNone",
Expand Down Expand Up @@ -182,10 +181,10 @@ func TestRisk_String(t *testing.T) {
func TestRemediationEffort_String(t *testing.T) {
t.Parallel()

tests := []struct { //nolint:govet
tests := []struct {
name string
effort RemediationEffort
want string
effort RemediationEffort
}{
{
name: "RemediationEffortNone",
Expand Down Expand Up @@ -228,10 +227,10 @@ func TestRemediationEffort_String(t *testing.T) {
func TestRisk_UnmarshalYAML(t *testing.T) {
t.Parallel()

tests := []struct { //nolint:govet
tests := []struct {
wantErr error
name string
input string
wantErr error
want Risk
}{
{
Expand Down Expand Up @@ -283,10 +282,10 @@ func TestRisk_UnmarshalYAML(t *testing.T) {
func TestRemediationEffort_UnmarshalYAML(t *testing.T) {
t.Parallel()

tests := []struct { //nolint:govet
tests := []struct {
wantErr error
name string
input string
wantErr error
want RemediationEffort
}{
{
Expand Down Expand Up @@ -328,10 +327,10 @@ func TestRemediationEffort_UnmarshalYAML(t *testing.T) {
func Test_validate(t *testing.T) {
t.Parallel()

tests := []struct { //nolint:govet
name string
rule *jsonRule
tests := []struct {
wantErr error
rule *jsonRule
name string
}{
{
name: "valid",
Expand Down

0 comments on commit f1d7a62

Please sign in to comment.