Skip to content

Commit 4642d9e

Browse files
committed
refactor: remove useless call to fileCache
1 parent b0a1ae1 commit 4642d9e

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

pkg/commands/run.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func (c *runCommand) preRunE(_ *cobra.Command, args []string) error {
217217

218218
pkgLoader := lint.NewPackageLoader(c.log.Child(logutils.DebugKeyLoader), c.cfg, args, c.goenv, guard)
219219

220-
c.contextBuilder = lint.NewContextBuilder(c.cfg, pkgLoader, c.fileCache, pkgCache, guard)
220+
c.contextBuilder = lint.NewContextBuilder(c.cfg, pkgLoader, pkgCache, guard)
221221

222222
if err = initHashSalt(c.buildInfo.Version, c.cfg); err != nil {
223223
return fmt.Errorf("failed to init hash salt: %w", err)

pkg/golinters/misspell/misspell.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"go/ast"
66
"go/token"
7+
"os"
78
"strings"
89
"unicode"
910

@@ -96,7 +97,7 @@ func runMisspellOnFile(lintCtx *linter.Context, pass *analysis.Pass, file *ast.F
9697
return nil
9798
}
9899

99-
fileContent, err := lintCtx.FileCache.GetFileBytes(position.Filename)
100+
fileContent, err := os.ReadFile(position.Filename)
100101
if err != nil {
101102
return fmt.Errorf("can't get file %s contents: %w", position.Filename, err)
102103
}

pkg/lint/context.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/golangci/golangci-lint/internal/cache"
88
"github.com/golangci/golangci-lint/pkg/config"
99
"github.com/golangci/golangci-lint/pkg/exitcodes"
10-
"github.com/golangci/golangci-lint/pkg/fsutils"
1110
"github.com/golangci/golangci-lint/pkg/goanalysis/load"
1211
"github.com/golangci/golangci-lint/pkg/lint/linter"
1312
"github.com/golangci/golangci-lint/pkg/logutils"
@@ -18,19 +17,17 @@ type ContextBuilder struct {
1817

1918
pkgLoader *PackageLoader
2019

21-
fileCache *fsutils.FileCache
22-
pkgCache *cache.Cache
20+
pkgCache *cache.Cache
2321

2422
loadGuard *load.Guard
2523
}
2624

2725
func NewContextBuilder(cfg *config.Config, pkgLoader *PackageLoader,
28-
fileCache *fsutils.FileCache, pkgCache *cache.Cache, loadGuard *load.Guard,
26+
pkgCache *cache.Cache, loadGuard *load.Guard,
2927
) *ContextBuilder {
3028
return &ContextBuilder{
3129
cfg: cfg,
3230
pkgLoader: pkgLoader,
33-
fileCache: fileCache,
3431
pkgCache: pkgCache,
3532
loadGuard: loadGuard,
3633
}
@@ -55,7 +52,6 @@ func (cl *ContextBuilder) Build(ctx context.Context, log logutils.Log, linters [
5552

5653
Cfg: cl.cfg,
5754
Log: log,
58-
FileCache: cl.fileCache,
5955
PkgCache: cl.pkgCache,
6056
LoadGuard: cl.loadGuard,
6157
}

pkg/lint/linter/context.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77

88
"github.com/golangci/golangci-lint/internal/cache"
99
"github.com/golangci/golangci-lint/pkg/config"
10-
"github.com/golangci/golangci-lint/pkg/fsutils"
1110
"github.com/golangci/golangci-lint/pkg/goanalysis/load"
1211
"github.com/golangci/golangci-lint/pkg/logutils"
1312
)
@@ -20,9 +19,8 @@ type Context struct {
2019
// version for each of packages
2120
OriginalPackages []*packages.Package
2221

23-
Cfg *config.Config
24-
FileCache *fsutils.FileCache
25-
Log logutils.Log
22+
Cfg *config.Config
23+
Log logutils.Log
2624

2725
PkgCache *cache.Cache
2826
LoadGuard *load.Guard

0 commit comments

Comments
 (0)