@@ -149,6 +149,21 @@ func (c *ConfigType) AddTools(configs []plugins.ToolConfig) error {
149149 }
150150
151151 if pluginConfig .Runtime != "" {
152+ // Special handling for dartanalyzer - check for existing dart or flutter runtimes
153+ if toolConfig .Name == "dartanalyzer" {
154+ // Check if either dart or flutter runtime is already available
155+ if runtimeInfo := c .runtimes ["flutter" ]; runtimeInfo != nil {
156+ // Flutter runtime exists, use it
157+ continue
158+ }
159+ if runtimeInfo := c .runtimes ["dart" ]; runtimeInfo != nil {
160+ // Dart runtime exists, use it
161+ continue
162+ }
163+ // Neither runtime exists, proceed with installing dart runtime
164+ pluginConfig .Runtime = "dart"
165+ }
166+
152167 runtimeInfo := c .runtimes [pluginConfig .Runtime ]
153168 if runtimeInfo == nil {
154169 // Get the default version for the runtime
@@ -159,6 +174,7 @@ func (c *ConfigType) AddTools(configs []plugins.ToolConfig) error {
159174 }
160175
161176 // Add the runtime to the config
177+ fmt .Println ("Adding missing runtime to codacy.yaml" , pluginConfig .Runtime , version )
162178 if err := c .AddRuntimes ([]plugins.RuntimeConfig {{Name : pluginConfig .Runtime , Version : version }}); err != nil {
163179 return fmt .Errorf ("failed to add runtime %s: %w" , pluginConfig .Runtime , err )
164180 }
@@ -322,20 +338,3 @@ func (c *ConfigType) IsToolInstalled(name string, tool *plugins.ToolInfo) bool {
322338
323339// Global singleton config-file
324340var Config = ConfigType {}
325-
326- // SaveConfig saves the current configuration to codacy.yaml
327- func (c * ConfigType ) SaveConfig () error {
328- // Convert config to YAML
329- yamlData , err := yaml .Marshal (c )
330- if err != nil {
331- return fmt .Errorf ("failed to marshal config to YAML: %w" , err )
332- }
333-
334- // Write to codacy.yaml
335- err = os .WriteFile ("codacy.yaml" , yamlData , 0644 )
336- if err != nil {
337- return fmt .Errorf ("failed to write config to codacy.yaml: %w" , err )
338- }
339-
340- return nil
341- }
0 commit comments