Skip to content

Commit cfa5aad

Browse files
fixing tests and adding logs
1 parent ab92926 commit cfa5aad

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

cmd/analyze.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"codacy/cli-v2/tools"
1111
"codacy/cli-v2/tools/lizard"
1212
reviveTool "codacy/cli-v2/tools/revive"
13+
"codacy/cli-v2/utils/logger"
1314
"encoding/json"
1415
"fmt"
1516
"log"
@@ -21,6 +22,7 @@ import (
2122

2223
codacyclient "codacy/cli-v2/codacy-client"
2324

25+
"github.com/sirupsen/logrus"
2426
"github.com/spf13/cobra"
2527
"gopkg.in/yaml.v3"
2628
)
@@ -301,12 +303,19 @@ func checkIfConfigExistsAndIsNeeded(toolName string, cliLocalMode bool) error {
301303
return fmt.Errorf("failed to create config file for tool %s: %w", toolName, err)
302304
}
303305
} else {
304-
fmt.Printf("Config file not found for tool %s: %s and no API token provided\n", toolName, toolConfigPath)
306+
logger.Warn("Config file not found for tool", logrus.Fields{
307+
"tool": toolName,
308+
"toolConfigPath": toolConfigPath,
309+
"message": "No API token provided",
310+
})
305311
}
306312
} else if err != nil {
307313
return fmt.Errorf("error checking config file for tool %s: %w", toolName, err)
308314
} else {
309-
fmt.Printf("Config file found for %s: %s\n", toolName, toolConfigPath)
315+
logger.Info("Config file found for tool", logrus.Fields{
316+
"tool": toolName,
317+
"toolConfigPath": toolConfigPath,
318+
})
310319
}
311320
return nil
312321
}

cmd/configsetup/setup.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,12 @@ func createToolFileConfiguration(tool domain.Tool, patternConfiguration []domain
518518
}
519519

520520
toolsConfigDir := config.Config.ToolsConfigDirectory()
521+
522+
// Ensure the tools-configs directory exists
523+
if err := os.MkdirAll(toolsConfigDir, constants.DefaultDirPerms); err != nil {
524+
return fmt.Errorf("failed to create tools-configs directory: %w", err)
525+
}
526+
521527
return creator.CreateConfig(toolsConfigDir, patternConfiguration)
522528
}
523529

0 commit comments

Comments
 (0)