Skip to content

Commit 5f00443

Browse files
committed
add dart/flutter analyse
1 parent 2c0be8d commit 5f00443

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

cmd/analyze.go

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ func getToolName(toolName string, version string) string {
190190

191191
var analyzeCmd = &cobra.Command{
192192
Use: "analyze",
193-
Short: "Runs all linters.",
194-
Long: "Runs all tools for all runtimes.",
193+
Short: "Runs selected tool.",
194+
Long: "Runs selected tool on defined runtime.",
195195
Run: func(cmd *cobra.Command, args []string) {
196196
workDirectory, err := os.Getwd()
197197
if err != nil {
@@ -201,7 +201,33 @@ var analyzeCmd = &cobra.Command{
201201
// TODO add more tools here
202202
switch toolToAnalyze {
203203
case "eslint":
204-
// nothing
204+
eslint := config.Config.Tools()["eslint"]
205+
eslintInstallationDirectory := eslint.Info()["installDir"]
206+
nodeRuntime := config.Config.Runtimes()["node"]
207+
nodeBinary := nodeRuntime.Info()["node"]
208+
209+
log.Printf("Running %s...\n", toolToAnalyze)
210+
if outputFormat == "sarif" {
211+
log.Println("Output will be in SARIF format")
212+
}
213+
214+
if outputFile != "" {
215+
log.Println("Output will be available at", outputFile)
216+
}
217+
218+
tools.RunEslint(workDirectory, eslintInstallationDirectory, nodeBinary, args, autoFix, outputFile, outputFormat)
219+
case "dartanalyzer":
220+
var dart *config.Runtime
221+
if config.Config.Runtimes()["flutter"] != nil {
222+
dart = config.Config.Runtimes()["flutter"]
223+
} else {
224+
dart = config.Config.Runtimes()["dart"]
225+
}
226+
dartInstallationDirectory := dart.Info()["installDir"]
227+
dartBinary := dart.Info()["dart"]
228+
229+
log.Printf("Running %s...\n", toolToAnalyze)
230+
tools.RunDartAnalyzer(workDirectory, dartInstallationDirectory, dartBinary, args, autoFix, outputFile, outputFormat)
205231
case "":
206232
log.Fatal("You need to specify a tool to run analysis with, e.g., '--tool eslint'", toolToAnalyze)
207233
default:
@@ -215,22 +241,6 @@ var analyzeCmd = &cobra.Command{
215241
failIfThereArePendingChanges()
216242
}
217243

218-
eslint := config.Config.Tools()["eslint"]
219-
eslintInstallationDirectory := eslint.Info()["installDir"]
220-
nodeRuntime := config.Config.Runtimes()["node"]
221-
nodeBinary := nodeRuntime.Info()["node"]
222-
223-
log.Printf("Running %s...\n", toolToAnalyze)
224-
if outputFormat == "sarif" {
225-
log.Println("Output will be in SARIF format")
226-
}
227-
228-
if outputFile != "" {
229-
log.Println("Output will be available at", outputFile)
230-
}
231-
232-
tools.RunEslint(workDirectory, eslintInstallationDirectory, nodeBinary, args, autoFix, outputFile, outputFormat)
233-
234244
if doNewPr {
235245
utils.CreatePr(false)
236246
}

0 commit comments

Comments
 (0)