1
0
mirror of https://github.com/mgechev/revive.git synced 2025-11-25 22:12:38 +02:00

refactor: removes get from getters names (#1373)

This commit is contained in:
chavacava
2025-05-24 19:03:05 +02:00
committed by GitHub
parent f531af3b48
commit 94cd7bdec2
7 changed files with 24 additions and 10 deletions

View File

@@ -101,24 +101,24 @@ var (
var originalUsage = flag.Usage
func getLogo() string {
func logo() string {
return color.YellowString(` _ __ _____ _(_)__ _____
| '__/ _ \ \ / / \ \ / / _ \
| | | __/\ V /| |\ V / __/
|_| \___| \_/ |_| \_/ \___|`)
}
func getCall() string {
func call() string {
return color.MagentaString("revive -config c.toml -formatter friendly -exclude a.go -exclude b.go ./...")
}
func getBanner() string {
func banner() string {
return fmt.Sprintf(`
%s
Example:
%s
`, getLogo(), getCall())
`, logo(), call())
}
func buildDefaultConfigPath() string {
@@ -150,7 +150,7 @@ func initConfig() {
}
flag.Usage = func() {
fmt.Println(getBanner())
fmt.Println(banner())
originalUsage()
}

View File

@@ -43,7 +43,7 @@ func (*Checkstyle) Format(failures <-chan lint.Failure, config lint.Config) (str
Severity: severity(config, failure),
RuleName: failure.RuleName,
}
fn := failure.GetFilename()
fn := failure.Filename()
if issues[fn] == nil {
issues[fn] = []issue{}
}

View File

@@ -68,7 +68,7 @@ func (*Friendly) printHeaderRow(sb *strings.Builder, failure lint.Failure, sever
}
func (*Friendly) printFilePosition(sb *strings.Builder, failure lint.Failure) {
fmt.Fprintf(sb, " %s:%d:%d", failure.GetFilename(), failure.Position.Start.Line, failure.Position.Start.Column)
fmt.Fprintf(sb, " %s:%d:%d", failure.Filename(), failure.Position.Start.Line, failure.Position.Start.Column)
}
type statEntry struct {

View File

@@ -27,7 +27,7 @@ func formatFailure(failure lint.Failure, severity lint.Severity) []string {
if severity == lint.SeverityWarning {
fName = color.YellowString(fURL)
}
return []string{failure.GetFilename(), pos, fName, fString}
return []string{failure.Filename(), pos, fName, fString}
}
// Format formats the failures gotten from the lint.

View File

@@ -81,7 +81,14 @@ type Failure struct {
}
// GetFilename returns the filename.
//
// Deprecated: Use [Filename].
func (f *Failure) GetFilename() string {
return f.Filename()
}
// Filename returns the filename.
func (f *Failure) Filename() string {
return f.Position.Start.Filename
}

View File

@@ -75,9 +75,9 @@ func (r *Revive) Lint(patterns ...*LintPattern) (<-chan lint.Failure, error) {
for _, lintpkg := range patterns {
if lintpkg.IsExclude() {
excludePatterns = append(excludePatterns, lintpkg.GetPattern())
excludePatterns = append(excludePatterns, lintpkg.Pattern())
} else {
includePatterns = append(includePatterns, lintpkg.GetPattern())
includePatterns = append(includePatterns, lintpkg.Pattern())
}
}

View File

@@ -12,7 +12,14 @@ func (p *LintPattern) IsExclude() bool {
}
// GetPattern - returns the actual pattern
//
// Deprecated: Use [Pattern].
func (p *LintPattern) GetPattern() string {
return p.Pattern()
}
// Pattern - returns the actual pattern
func (p *LintPattern) Pattern() string {
return p.pattern
}