Skip to content

Commit f27f124

Browse files
committed
lintcmd: unexport the majority of the API
1 parent 9563186 commit f27f124

File tree

6 files changed

+93
-93
lines changed

6 files changed

+93
-93
lines changed

lintcmd/cmd.go

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
"golang.org/x/tools/go/buildutil"
3131
)
3232

33-
type BuildConfig struct {
33+
type buildConfig struct {
3434
Name string
3535
Envs []string
3636
Flags []string
@@ -235,16 +235,16 @@ type run struct {
235235
diagnostics map[diagnosticDescriptor]diagnostic
236236
}
237237

238-
func runFromLintResult(res LintResult) run {
238+
func runFromLintResult(res lintResult) run {
239239
out := run{
240240
checkedFiles: map[string]struct{}{},
241241
diagnostics: map[diagnosticDescriptor]diagnostic{},
242242
}
243243

244-
for _, cf := range res.CheckedFiles {
244+
for _, cf := range res.checkedFiles {
245245
out.checkedFiles[cf] = struct{}{}
246246
}
247-
for _, diag := range res.Diagnostics {
247+
for _, diag := range res.diagnostics {
248248
out.diagnostics[diag.descriptor()] = diag
249249
}
250250
return out
@@ -253,7 +253,7 @@ func runFromLintResult(res LintResult) run {
253253
func decodeGob(br io.ByteReader) ([]run, error) {
254254
var runs []run
255255
for {
256-
var res LintResult
256+
var res lintResult
257257
if err := gob.NewDecoder(br.(io.Reader)).Decode(&res); err != nil {
258258
if err == io.EOF {
259259
break
@@ -383,7 +383,7 @@ func (cmd *Command) Run() {
383383
cmd.exit(2)
384384
}
385385

386-
var bconfs []BuildConfig
386+
var bconfs []buildConfig
387387
if cmd.flags.matrix {
388388
if cmd.flags.tags != "" {
389389
fmt.Fprintln(os.Stderr, "cannot use -matrix and -tags together")
@@ -401,7 +401,7 @@ func (cmd *Command) Run() {
401401
os.Exit(2)
402402
}
403403
} else {
404-
bc := BuildConfig{}
404+
bc := buildConfig{}
405405
if cmd.flags.tags != "" {
406406
// Validate that the tags argument is well-formed. go/packages
407407
// doesn't detect malformed build flags and returns unhelpful
@@ -420,20 +420,20 @@ func (cmd *Command) Run() {
420420
var runs []run
421421
for _, bconf := range bconfs {
422422
res, err := doLint(cs, cmd.flags.fs.Args(), &options{
423-
BuildConfig: bconf,
424-
LintTests: cmd.flags.tests,
425-
GoVersion: string(cmd.flags.goVersion),
426-
Config: config.Config{
423+
buildConfig: bconf,
424+
lintTests: cmd.flags.tests,
425+
goVersion: string(cmd.flags.goVersion),
426+
config: config.Config{
427427
Checks: cmd.flags.checks,
428428
},
429-
PrintAnalyzerMeasurement: measureAnalyzers,
429+
printAnalyzerMeasurement: measureAnalyzers,
430430
})
431431
if err != nil {
432432
fmt.Fprintln(os.Stderr, err)
433433
cmd.exit(1)
434434
}
435435

436-
for _, w := range res.Warnings {
436+
for _, w := range res.warnings {
437437
fmt.Fprintln(os.Stderr, "warning:", w)
438438
}
439439

@@ -453,18 +453,18 @@ func (cmd *Command) Run() {
453453
}
454454

455455
if cmd.flags.formatter == "binary" {
456-
for i, s := range res.CheckedFiles {
457-
res.CheckedFiles[i] = relPath(s)
456+
for i, s := range res.checkedFiles {
457+
res.checkedFiles[i] = relPath(s)
458458
}
459-
for i := range res.Diagnostics {
459+
for i := range res.diagnostics {
460460
// We turn all paths into relative, /-separated paths. This is to make -merge work correctly when
461461
// merging runs from different OSs, with different absolute paths.
462462
//
463463
// We zero out Offset, because checkouts of code on different OSs may have different kinds of
464464
// newlines and thus different offsets. We don't ever make use of the Offset, anyway. Line and
465465
// column numbers are precomputed.
466466

467-
d := &res.Diagnostics[i]
467+
d := &res.diagnostics[i]
468468
d.Position.Filename = relPath(d.Position.Filename)
469469
d.Position.Offset = 0
470470
d.End.Filename = relPath(d.End.Filename)
@@ -498,7 +498,7 @@ func mergeRuns(runs []run) []diagnostic {
498498
var relevantDiagnostics []diagnostic
499499
for _, r := range runs {
500500
for _, diag := range r.diagnostics {
501-
switch diag.MergeIf {
501+
switch diag.mergeIf {
502502
case lint.MergeIfAny:
503503
relevantDiagnostics = append(relevantDiagnostics, diag)
504504
case lint.MergeIfAll:
@@ -557,8 +557,8 @@ func (cmd *Command) printDiagnostics(cs []*lint.Analyzer, diagnostics []diagnost
557557
if di.Message != dj.Message {
558558
return di.Message < dj.Message
559559
}
560-
if di.BuildName != dj.BuildName {
561-
return di.BuildName < dj.BuildName
560+
if di.buildName != dj.buildName {
561+
return di.buildName < dj.buildName
562562
}
563563
return di.Category < dj.Category
564564
})
@@ -567,7 +567,7 @@ func (cmd *Command) printDiagnostics(cs []*lint.Analyzer, diagnostics []diagnost
567567
diagnostics[0],
568568
}
569569
builds := []map[string]struct{}{
570-
{diagnostics[0].BuildName: {}},
570+
{diagnostics[0].buildName: {}},
571571
}
572572
for _, diag := range diagnostics[1:] {
573573
// We may encounter duplicate diagnostics because one file
@@ -576,11 +576,11 @@ func (cmd *Command) printDiagnostics(cs []*lint.Analyzer, diagnostics []diagnost
576576
if !filtered[len(filtered)-1].equal(diag) {
577577
if filtered[len(filtered)-1].descriptor() == diag.descriptor() {
578578
// Diagnostics only differ in build name, track new name
579-
builds[len(filtered)-1][diag.BuildName] = struct{}{}
579+
builds[len(filtered)-1][diag.buildName] = struct{}{}
580580
} else {
581581
filtered = append(filtered, diag)
582582
builds = append(builds, map[string]struct{}{})
583-
builds[len(filtered)-1][diag.BuildName] = struct{}{}
583+
builds[len(filtered)-1][diag.buildName] = struct{}{}
584584
}
585585
}
586586
}
@@ -592,7 +592,7 @@ func (cmd *Command) printDiagnostics(cs []*lint.Analyzer, diagnostics []diagnost
592592
names = append(names, k)
593593
}
594594
sort.Strings(names)
595-
filtered[i].BuildName = strings.Join(names, ",")
595+
filtered[i].buildName = strings.Join(names, ",")
596596
}
597597
diagnostics = filtered
598598
}
@@ -643,14 +643,14 @@ func (cmd *Command) printDiagnostics(cs []*lint.Analyzer, diagnostics []diagnost
643643
if diag.Category == "compile" && cmd.flags.debugNoCompileErrors {
644644
continue
645645
}
646-
if diag.Severity == severityIgnored && !cmd.flags.showIgnored {
646+
if diag.severity == severityIgnored && !cmd.flags.showIgnored {
647647
numIgnored++
648648
continue
649649
}
650650
if shouldExit[diag.Category] {
651651
numErrors++
652652
} else {
653-
diag.Severity = severityWarning
653+
diag.severity = severityWarning
654654
numWarnings++
655655
}
656656
notIgnored = append(notIgnored, diag)

lintcmd/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ type parseBuildConfigError struct {
1616

1717
func (err parseBuildConfigError) Error() string { return err.err.Error() }
1818

19-
func parseBuildConfigs(r io.Reader) ([]BuildConfig, error) {
20-
var builds []BuildConfig
19+
func parseBuildConfigs(r io.Reader) ([]buildConfig, error) {
20+
var builds []buildConfig
2121
br := bufio.NewReader(r)
2222
i := 0
2323
for {
@@ -38,7 +38,7 @@ func parseBuildConfigs(r io.Reader) ([]BuildConfig, error) {
3838
return nil, parseBuildConfigError{line: i + 1, err: err}
3939
}
4040

41-
bc := BuildConfig{
41+
bc := buildConfig{
4242
Name: name,
4343
Envs: envs,
4444
Flags: flags,

lintcmd/directives.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func parseDirectives(dirs []runner.SerializedDirective) ([]ignore, []diagnostic)
2222
Message: "malformed linter directive; missing the required reason field?",
2323
Category: "compile",
2424
},
25-
Severity: severityError,
25+
severity: severityError,
2626
}
2727
diagnostics = append(diagnostics, p)
2828
continue

lintcmd/format.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (o jsonFormatter) Format(_ []*lint.Analyzer, ps []diagnostic) {
8989
Related []related `json:"related,omitempty"`
9090
}{
9191
Code: p.Category,
92-
Severity: p.Severity.String(),
92+
Severity: p.severity.String(),
9393
Location: location{
9494
File: p.Position.Filename,
9595
Line: p.Position.Line,

0 commit comments

Comments
 (0)