From fc882e4f4d6704207ddb09641e6b2e15cbf73342 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Tue, 10 Dec 2024 05:41:56 +0100 Subject: [PATCH] fix: add an human understanable report message Signed-off-by: Fernandez Ludovic --- pkg/analyzer/analyzer.go | 38 ++------------------------------------ 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/pkg/analyzer/analyzer.go b/pkg/analyzer/analyzer.go index c664b4c..f3a7f38 100644 --- a/pkg/analyzer/analyzer.go +++ b/pkg/analyzer/analyzer.go @@ -1,7 +1,6 @@ package analyzer import ( - "fmt" "go/token" "strings" @@ -89,8 +88,7 @@ func runAnalysis(pass *analysis.Pass) (interface{}, error) { } for _, file := range fileReferences { - filePath := file.Name() - unmodifiedFile, formattedFile, err := gci.LoadFormatGoFile(io.File{FilePath: filePath}, *gciCfg) + unmodifiedFile, formattedFile, err := gci.LoadFormatGoFile(io.File{FilePath: file.Name()}, *gciCfg) if err != nil { return nil, err } @@ -107,7 +105,7 @@ func runAnalysis(pass *analysis.Pass) (interface{}, error) { pass.Report(analysis.Diagnostic{ Pos: fix.TextEdits[0].Pos, - Message: fmt.Sprintf("fix by `%s %s`", generateCmdLine(*gciCfg), filePath), + Message: "Invalid import order", SuggestedFixes: []analysis.SuggestedFix{*fix}, }) } @@ -140,35 +138,3 @@ func generateGciConfiguration(modPath string) *config.YamlConfig { return &config.YamlConfig{Cfg: fmtCfg, SectionStrings: sectionStrings, SectionSeparatorStrings: sectionSeparatorStrings, ModPath: modPath} } - -func generateCmdLine(cfg config.Config) string { - result := "gci write" - - if cfg.BoolConfig.NoInlineComments { - result += " --NoInlineComments " - } - - if cfg.BoolConfig.NoPrefixComments { - result += " --NoPrefixComments " - } - - if cfg.BoolConfig.SkipGenerated { - result += " --skip-generated " - } - - if cfg.BoolConfig.CustomOrder { - result += " --custom-order " - } - - if cfg.BoolConfig.NoLexOrder { - result += " --no-lex-order" - } - - for _, s := range cfg.Sections.String() { - result += fmt.Sprintf(" --Section \"%s\" ", s) - } - for _, s := range cfg.SectionSeparators.String() { - result += fmt.Sprintf(" --SectionSeparator %s ", s) - } - return result -}