Skip to content

Commit f04aa4a

Browse files
code review changes
1 parent c55c3a8 commit f04aa4a

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

cmd/analyze.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -308,14 +308,16 @@ func checkIfConfigExistsAndIsNeeded(toolName string, cliLocalMode bool) error {
308308
// Only show error if we're in remote mode and need the config file
309309
if !cliLocalMode && initFlags.ApiToken != "" {
310310
fmt.Printf("Creating new config file for tool %s\n", toolName)
311-
configsetup.CreateToolConfigurationFile(toolName, initFlags)
311+
if err := configsetup.CreateToolConfigurationFile(toolName, initFlags); err != nil {
312+
return fmt.Errorf("failed to create config file for tool %s: %w", toolName, err)
313+
}
312314
} else if !cliLocalMode {
313-
fmt.Printf("config file not found for tool %s: %s and no api token provided \n", toolName, toolConfigPath)
315+
fmt.Printf("Config file not found for tool %s: %s and no API token provided\n", toolName, toolConfigPath)
314316
} else {
315-
fmt.Printf("config file not found for tool %s: %s please add a config file to the tools-configs directory\n", toolName, toolConfigPath)
317+
fmt.Printf("Config file not found for tool %s: %s. Please add a config file to the tools-configs directory\n", toolName, toolConfigPath)
316318
}
317319
} else if err != nil {
318-
fmt.Printf("error checking config file for tool %s: %v\n", toolName, err)
320+
return fmt.Errorf("Error checking config file for tool %s: %w", toolName, err)
319321
} else {
320322
fmt.Printf("Config file found for %s: %s\n", toolName, toolConfigPath)
321323
}
@@ -363,7 +365,7 @@ func runTool(workDirectory string, toolName string, pathsToCheck []string, outpu
363365
return err
364366
}
365367
log.Println("Running tools for the specified file(s)...")
366-
log.Printf("Running %s...\n", toolName)
368+
log.Printf("Running %s...", toolName)
367369

368370
tool := config.Config.Tools()[toolName]
369371
var isToolInstalled bool
@@ -395,7 +397,7 @@ func runTool(workDirectory string, toolName string, pathsToCheck []string, outpu
395397
runtime = config.Config.Runtimes()[tool.Runtime]
396398
isRuntimeInstalled = runtime == nil || config.Config.IsRuntimeInstalled(tool.Runtime, runtime)
397399
if !isRuntimeInstalled {
398-
fmt.Printf("%s runtime is not installed, installing...\n", tool.Runtime)
400+
fmt.Printf("%s runtime is not installed, installing...", tool.Runtime)
399401
err := config.InstallRuntime(tool.Runtime, runtime)
400402
if err != nil {
401403
return fmt.Errorf("failed to install %s runtime: %w", tool.Runtime, err)
@@ -407,7 +409,7 @@ func runTool(workDirectory string, toolName string, pathsToCheck []string, outpu
407409
runtime = config.Config.Runtimes()[tool.Runtime]
408410
isRuntimeInstalled = runtime == nil || config.Config.IsRuntimeInstalled(tool.Runtime, runtime)
409411
if !isRuntimeInstalled {
410-
fmt.Printf("%s runtime is not installed, installing...\n", tool.Runtime)
412+
fmt.Printf("%s runtime is not installed, installing...", tool.Runtime)
411413
err := config.InstallRuntime(tool.Runtime, runtime)
412414
if err != nil {
413415
return fmt.Errorf("failed to install %s runtime: %w", tool.Runtime, err)
@@ -438,7 +440,9 @@ func validateCloudMode(cliLocalMode bool) error {
438440
var analyzeCmd = &cobra.Command{
439441
Use: "analyze",
440442
Short: "Analyze code using configured tools",
441-
Long: `Analyze code using configured tools and output results in the specified format.`,
443+
Long: `Analyze code using configured tools and output results in the specified format.
444+
445+
Supports API token, provider, and repository flags to automatically fetch tool configurations from Codacy API if they don't exist locally.`,
442446
Run: func(cmd *cobra.Command, args []string) {
443447
// Validate paths before proceeding
444448
if err := validatePaths(args); err != nil {

tools/eslintConfigCreator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func CreateEslintConfig(toolsConfigDir string, configuration []domain.PatternCon
199199
}
200200

201201
// Check if this rule accepts options
202-
if rulesWithoutOptions[rule] {
202+
if _, ok := rulesWithoutOptions[rule]; ok {
203203
// Rule doesn't accept options, only use error level
204204
result += " "
205205
result += fmt.Sprintf(`"%s": ["error"],`, rule)

0 commit comments

Comments
 (0)