Skip to content

Commit dc64451

Browse files
committed
refactor: Rename maintainers annotation to annotations
Renaming flags, function params, docs and fixing config renamings. Signed-off-by: Gabriela Gutierrez <[email protected]>
1 parent 98b604e commit dc64451

File tree

9 files changed

+60
-60
lines changed

9 files changed

+60
-60
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,9 @@ RESULTS
419419
|---------|------------------------|--------------------------------|--------------------------------|---------------------------------------------------------------------------|
420420
```
421421

422-
##### Showing Maintainers Annotation
422+
##### Showing Maintainers Annotations
423423

424-
To see maintainers annotations for each check, use the `--show-ma` option.
424+
To see the maintainers annotations for each check, use the `--show-annotations` option.
425425

426426
##### Using a GitLab Repository
427427

checker/check_result.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ func LogFindings(findings []finding.Finding, dl DetailLogger) {
265265
}
266266
}
267267

268-
// IsExempted verifies if a given check in the results is exempted in maintainers annotation.
268+
// IsExempted verifies if a given check in the results is exempted in annotations.
269269
func (check *CheckResult) IsExempted(c config.Config) (bool, []string) {
270270
// If check has a maximum score, then there it doesn't make sense anymore to reason the check
271271
// This may happen if the check score was once low but then the problem was fixed on Scorecard side

config/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Maintainers Annotation
1+
# Maintainers Annotations
22

3-
Maintainers Annotation is an experimental feature to let maintainers add annotations to Scorecard checks.
3+
Maintainers Annotations is an experimental feature to let maintainers add annotations to Scorecard checks.
44

5-
## Showing Maintainers Annotation
5+
## Showing Maintainers Annotations
66

7-
To see maintainers annotations for each check on Scorecard results, use the `--show-ma` option.
7+
To see the maintainers annotations for each check on Scorecard results, use the `--show-annotations` option.
88

99
## Adding Annotations
1010

options/flags.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ const (
5454
// FlagShowDetails is the flag name for outputting additional check info.
5555
FlagShowDetails = "show-details"
5656

57-
// FlagShowMaintainersAnnotation is the flag name for outputting maintainers annotations on checks.
58-
FlagShowMaintainersAnnotation = "show-ma"
57+
// FlagShowAnnotations is the flag name for outputting annotations on checks.
58+
FlagShowAnnotations = "show-annotations"
5959

6060
// FlagChecks is the flag name for specifying which checks to run.
6161
FlagChecks = "checks"
@@ -157,9 +157,9 @@ func (o *Options) AddFlags(cmd *cobra.Command) {
157157

158158
if o.isExperimentalEnabled() {
159159
cmd.Flags().BoolVar(
160-
&o.ShowMaintainersAnnotation,
161-
FlagShowMaintainersAnnotation,
162-
o.ShowMaintainersAnnotation,
160+
&o.ShowAnnotations,
161+
FlagShowAnnotations,
162+
o.ShowAnnotations,
163163
"show maintainers annotations for checks",
164164
)
165165
}

options/options.go

+17-17
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,23 @@ import (
3030

3131
// Options define common options for configuring scorecard.
3232
type Options struct {
33-
Repo string
34-
Local string
35-
Commit string
36-
LogLevel string
37-
Format string
38-
NPM string
39-
PyPI string
40-
RubyGems string
41-
Nuget string
42-
PolicyFile string
43-
ResultsFile string
44-
ChecksToRun []string
45-
ProbesToRun []string
46-
Metadata []string
47-
CommitDepth int
48-
ShowDetails bool
49-
ShowMaintainersAnnotation bool
33+
Repo string
34+
Local string
35+
Commit string
36+
LogLevel string
37+
Format string
38+
NPM string
39+
PyPI string
40+
RubyGems string
41+
Nuget string
42+
PolicyFile string
43+
ResultsFile string
44+
ChecksToRun []string
45+
ProbesToRun []string
46+
Metadata []string
47+
CommitDepth int
48+
ShowDetails bool
49+
ShowAnnotations bool
5050
// Feature flags.
5151
EnableSarif bool `env:"ENABLE_SARIF"`
5252
EnableScorecardV6 bool `env:"SCORECARD_V6"`

pkg/json.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ type jsonCheckDocumentationV2 struct {
4949

5050
//nolint:govet
5151
type jsonCheckResultV2 struct {
52-
Details []string `json:"details"`
53-
Score int `json:"score"`
54-
Reason string `json:"reason"`
55-
Name string `json:"name"`
56-
Doc jsonCheckDocumentationV2 `json:"documentation"`
57-
MaintainersAnnotation []string `json:"maintainersAnnotation"`
52+
Details []string `json:"details"`
53+
Score int `json:"score"`
54+
Reason string `json:"reason"`
55+
Name string `json:"name"`
56+
Doc jsonCheckDocumentationV2 `json:"documentation"`
57+
Annotations []string `json:"annotations"`
5858
}
5959

6060
type jsonRepoV2 struct {
@@ -123,7 +123,7 @@ func (r *ScorecardResult) AsJSON(showDetails bool, logLevel log.Level, writer io
123123

124124
// AsJSON2 exports results as JSON for new detail format.
125125
func (r *ScorecardResult) AsJSON2(showDetails bool,
126-
showMaintainersAnnotation bool, logLevel log.Level,
126+
showAnnotations bool, logLevel log.Level,
127127
checkDocs docs.Doc, writer io.Writer,
128128
) error {
129129
score, err := r.GetAggregateScore(checkDocs)
@@ -174,10 +174,10 @@ func (r *ScorecardResult) AsJSON2(showDetails bool,
174174
tmpResult.Details = append(tmpResult.Details, m)
175175
}
176176
}
177-
if showMaintainersAnnotation {
178-
exempted, reasons := checkResult.IsExempted(r.MaintainersAnnotation)
177+
if showAnnotations {
178+
exempted, reasons := checkResult.IsExempted(r.Config)
179179
if exempted {
180-
tmpResult.MaintainersAnnotation = reasons
180+
tmpResult.Annotations = reasons
181181
}
182182
}
183183
out.Checks = append(out.Checks, tmpResult)

pkg/sarif.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ func (r *ScorecardResult) AsSARIF(showDetails bool, logLevel log.Level,
628628
check := check
629629

630630
// If check is exempted, skip
631-
exempted, _ := check.IsExempted(r.MaintainersAnnotation)
631+
exempted, _ := check.IsExempted(r.Config)
632632
if exempted {
633633
continue
634634
}

pkg/scorecard.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ import (
2828

2929
"github.com/ossf/scorecard/v4/checker"
3030
"github.com/ossf/scorecard/v4/clients"
31+
"github.com/ossf/scorecard/v4/config"
3132
sce "github.com/ossf/scorecard/v4/errors"
3233
"github.com/ossf/scorecard/v4/finding"
33-
ma "github.com/ossf/scorecard/v4/maintainers_annotation"
3434
"github.com/ossf/scorecard/v4/options"
3535
"github.com/ossf/scorecard/v4/probes"
3636
"github.com/ossf/scorecard/v4/probes/zrunner"
@@ -164,12 +164,12 @@ func runScorecard(ctx context.Context,
164164
// If the user runs checks
165165
go runEnabledChecks(ctx, repo, request, checksToRun, resultsCh)
166166

167-
// Get maintainers annotation
168-
maintainersAnnotation, err := ma.GetMaintainersAnnotation(repoClient)
167+
// Get configuration
168+
c, err := config.Parse(repoClient)
169169
if err != nil {
170170
return ScorecardResult{}, err
171171
}
172-
ret.MaintainersAnnotation = maintainersAnnotation
172+
ret.Config = c
173173

174174
for result := range resultsCh {
175175
ret.Checks = append(ret.Checks, result)

pkg/scorecard_result.go

+16-16
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ import (
3030
"github.com/ossf/scorecard/v4/checks/raw/gitlab"
3131
"github.com/ossf/scorecard/v4/clients/githubrepo"
3232
"github.com/ossf/scorecard/v4/clients/gitlabrepo"
33+
"github.com/ossf/scorecard/v4/config"
3334
docChecks "github.com/ossf/scorecard/v4/docs/checks"
3435
sce "github.com/ossf/scorecard/v4/errors"
3536
"github.com/ossf/scorecard/v4/finding"
3637
"github.com/ossf/scorecard/v4/log"
37-
ma "github.com/ossf/scorecard/v4/maintainers_annotation"
3838
"github.com/ossf/scorecard/v4/options"
3939
spol "github.com/ossf/scorecard/v4/policy"
4040
"github.com/ossf/scorecard/v4/probes"
@@ -54,14 +54,14 @@ type RepoInfo struct {
5454

5555
// ScorecardResult struct is returned on a successful Scorecard run.
5656
type ScorecardResult struct {
57-
Repo RepoInfo
58-
Date time.Time
59-
Scorecard ScorecardInfo
60-
Checks []checker.CheckResult
61-
RawResults checker.RawResults
62-
Findings []finding.Finding
63-
Metadata []string
64-
MaintainersAnnotation ma.MaintainersAnnotation
57+
Repo RepoInfo
58+
Date time.Time
59+
Scorecard ScorecardInfo
60+
Checks []checker.CheckResult
61+
RawResults checker.RawResults
62+
Findings []finding.Finding
63+
Metadata []string
64+
Config config.Config
6565
}
6666

6767
func scoreToString(s float64) string {
@@ -132,12 +132,12 @@ func FormatResults(
132132

133133
switch opts.Format {
134134
case options.FormatDefault:
135-
err = results.AsString(opts.ShowDetails, opts.ShowMaintainersAnnotation, log.ParseLevel(opts.LogLevel), doc, output)
135+
err = results.AsString(opts.ShowDetails, opts.ShowAnnotations, log.ParseLevel(opts.LogLevel), doc, output)
136136
case options.FormatSarif:
137137
// TODO: support config files and update checker.MaxResultScore.
138138
err = results.AsSARIF(opts.ShowDetails, log.ParseLevel(opts.LogLevel), output, doc, policy, opts)
139139
case options.FormatJSON:
140-
err = results.AsJSON2(opts.ShowDetails, opts.ShowMaintainersAnnotation, log.ParseLevel(opts.LogLevel), doc, output)
140+
err = results.AsJSON2(opts.ShowDetails, opts.ShowAnnotations, log.ParseLevel(opts.LogLevel), doc, output)
141141
case options.FormatFJSON:
142142
err = results.AsFJSON(opts.ShowDetails, log.ParseLevel(opts.LogLevel), doc, output)
143143
case options.FormatPJSON:
@@ -164,7 +164,7 @@ func FormatResults(
164164

165165
// AsString returns ScorecardResult in string format.
166166
func (r *ScorecardResult) AsString(showDetails bool,
167-
showMaintainersAnnotation bool, logLevel log.Level,
167+
showAnnotations bool, logLevel log.Level,
168168
checkDocs docChecks.Doc, writer io.Writer,
169169
) error {
170170
data := make([][]string, len(r.Checks))
@@ -194,8 +194,8 @@ func (r *ScorecardResult) AsString(showDetails bool,
194194
}
195195
}
196196
x = append(x, doc)
197-
if showMaintainersAnnotation {
198-
_, reasons := row.IsExempted(r.MaintainersAnnotation)
197+
if showAnnotations {
198+
_, reasons := row.IsExempted(r.Config)
199199
x = append(x, strings.Join(reasons, "\n"))
200200
}
201201
data[i] = x
@@ -218,8 +218,8 @@ func (r *ScorecardResult) AsString(showDetails bool,
218218
header = append(header, "Details")
219219
}
220220
header = append(header, "Documentation/Remediation")
221-
if showMaintainersAnnotation {
222-
header = append(header, "Maintainers Annotation")
221+
if showAnnotations {
222+
header = append(header, "Annotation")
223223
}
224224
table.SetHeader(header)
225225
table.SetBorders(tablewriter.Border{Left: true, Top: true, Right: true, Bottom: true})

0 commit comments

Comments
 (0)