Skip to content

Commit f945471

Browse files
committed
Tidying up more code
No functional changes here, or at lest not intentionally so 😅 Just making code a bit more short and to the point where possible. Some things to disagree with maybe, and let me know if so as I'm open to suggestions. Signed-off-by: Anders Eknert <anders@styra.com>
1 parent 65351f9 commit f945471

8 files changed

Lines changed: 176 additions & 330 deletions

File tree

cmd/fix.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,7 @@ func fix(args []string, params *fixParams) (err error) {
196196
return fmt.Errorf("could not find potential roots: %w", err)
197197
}
198198

199-
f := fixer.NewFixer()
200-
f.RegisterRoots(roots...)
201-
f.RegisterFixes(fixes.NewDefaultFixes()...)
199+
f := fixer.NewFixer().RegisterRoots(roots...).RegisterFixes(fixes.NewDefaultFixes()...)
202200

203201
if userConfigFile != nil {
204202
versionsMap, err := config.AllRegoVersions(filepath.Dir(userConfigFile.Name()), &userConfig)

internal/lsp/eval.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313

1414
rbundle "github.com/styrainc/regal/bundle"
1515
"github.com/styrainc/regal/internal/lsp/log"
16-
"github.com/styrainc/regal/internal/lsp/uri"
1716
"github.com/styrainc/regal/pkg/builtins"
1817
"github.com/styrainc/regal/pkg/config"
1918
"github.com/styrainc/regal/pkg/roast/transform"
@@ -43,12 +42,7 @@ func (l *LanguageServer) Eval(
4342
var hasCustomRules bool
4443

4544
for fileURI, module := range modules {
46-
moduleFiles = append(moduleFiles, bundle.ModuleFile{
47-
URL: fileURI,
48-
Parsed: module,
49-
Path: uri.ToPath(l.clientIdentifier, fileURI),
50-
})
51-
45+
moduleFiles = append(moduleFiles, bundle.ModuleFile{URL: fileURI, Parsed: module, Path: l.toPath(fileURI)})
5246
hasCustomRules = hasCustomRules || strings.Contains(module.Package.Path.String(), "custom.regal.rules")
5347
}
5448

0 commit comments

Comments
 (0)