Skip to content

Commit

Permalink
fix: read files from disk
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Dec 24, 2024
1 parent 27ba895 commit 636293c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pkg/lint/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func NewRunner(log logutils.Log, cfg *config.Config, args []string, goenv *gouti
return nil, fmt.Errorf("failed to get enabled linters: %w", err)
}

formatter, err := processors.NewFormatter(log, cfg, fileCache, enabledLinters)
formatter, err := processors.NewFormatter(log, cfg, enabledLinters)
if err != nil {
return nil, fmt.Errorf("failed to create formatter: %w", err)
}
Expand Down Expand Up @@ -100,7 +100,7 @@ func NewRunner(log logutils.Log, cfg *config.Config, args []string, goenv *gouti

// The fixer still needs to see paths for the issues that are relative to the current directory.
processors.NewFixer(cfg, log, fileCache),
// The fommatter needs to be after the fixer and the last processor that use fileCache.
// The formatter needs to be after the fixer and the last processor that write files.
formatter,

// Now we can modify the issues for output.
Expand Down
10 changes: 3 additions & 7 deletions pkg/result/processors/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"slices"

"github.com/golangci/golangci-lint/pkg/config"
"github.com/golangci/golangci-lint/pkg/fsutils"
"github.com/golangci/golangci-lint/pkg/goformatters"
"github.com/golangci/golangci-lint/pkg/goformatters/gci"
"github.com/golangci/golangci-lint/pkg/goformatters/gofmt"
Expand All @@ -21,17 +20,14 @@ import (
type Formatter struct {
log logutils.Log
cfg *config.Config
fileCache *fsutils.FileCache
formatters []goformatters.Formatter
}

func NewFormatter(log logutils.Log, cfg *config.Config,
fileCache *fsutils.FileCache,
enabledLinters map[string]*linter.Config) (*Formatter, error) {
p := &Formatter{
log: log,
cfg: cfg,
fileCache: fileCache,
log: log,
cfg: cfg,
}

if _, ok := enabledLinters[gofmt.Name]; ok {
Expand Down Expand Up @@ -108,7 +104,7 @@ func (p *Formatter) Process(issues []result.Issue) ([]result.Issue, error) {
}

for target := range files {
content, err := p.fileCache.GetFileBytes(target)
content, err := os.ReadFile(target)
if err != nil {
p.log.Warnf("Error reading file %s: %v", target, err)
continue
Expand Down

0 comments on commit 636293c

Please sign in to comment.