• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 20003978026

07 Dec 2025 12:09PM UTC coverage: 70.101% (+0.2%) from 69.903%
20003978026

push

github

web-flow
#39: refactoring to extract package-manager logic out of node/npm (#1638)

3892 of 6090 branches covered (63.91%)

Branch coverage included in aggregate %.

9955 of 13663 relevant lines covered (72.86%)

3.15 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

9.26
cli/src/main/java/com/devonfw/tools/ide/tool/sonar/Sonar.java
1
package com.devonfw.tools.ide.tool.sonar;
2

3
import java.nio.file.Path;
4
import java.util.List;
5
import java.util.Properties;
6
import java.util.Set;
7

8
import com.devonfw.tools.ide.common.Tag;
9
import com.devonfw.tools.ide.context.IdeContext;
10
import com.devonfw.tools.ide.property.EnumProperty;
11
import com.devonfw.tools.ide.tool.LocalToolCommandlet;
12
import com.devonfw.tools.ide.tool.ToolInstallation;
13
import com.devonfw.tools.ide.tool.java.Java;
14
import com.devonfw.tools.ide.tool.mvn.Mvn;
15

16
public class Sonar extends LocalToolCommandlet {
17

18
  public final EnumProperty<SonarCommand> command;
19

20
  /**
21
   * The constructor.
22
   *
23
   * @param context the {@link IdeContext}. method.
24
   */
25
  public Sonar(IdeContext context) {
26

27
    super(context, "sonar", Set.of(Tag.CODE_QA));
6✔
28

29
    this.command = add(new EnumProperty<>("", true, "command", SonarCommand.class));
12✔
30
    add(this.arguments);
5✔
31
  }
1✔
32

33
  @Override
34
  protected void initProperties() {
35

36
    // Empty on purpose
37
  }
1✔
38

39
  @Override
40
  public ToolInstallation install(boolean silent) {
41

42
    getCommandlet(Java.class).install();
×
43
    return super.install(silent);
×
44
  }
45

46
  @Override
47
  public void run() {
48

49
    SonarCommand command = this.command.getValue();
×
50

51
    Path toolPath = getToolPath();
×
52
    if (!toolPath.toFile().exists()) {
×
53
      super.install(true);
×
54
    }
55

56
    switch (command) {
×
57
      case ANALYZE:
58
        getCommandlet(Mvn.class).runTool(List.of("sonar:sonar"));
×
59
        break;
×
60
      case START:
61
        printSonarWebPort();
×
62
        this.arguments.setValueAsString("start", this.context);
×
63
        super.run();
×
64
        break;
×
65
      case STOP:
66
        this.arguments.setValueAsString("stop", this.context);
×
67
        super.run();
×
68
        break;
×
69
      default:
70
    }
71
  }
×
72

73
  @Override
74
  protected String getBinaryName() {
75

76
    if (this.context.getSystemInfo().isWindows()) {
×
77
      SonarCommand command = this.command.getValue();
×
78
      if (command.equals(SonarCommand.START)) {
×
79
        return "windows-x86-64/StartSonar.bat";
×
80
      } else if (command.equals(SonarCommand.STOP)) {
×
81
        return "windows-x86-64/SonarService.bat";
×
82
      }
83
    } else if (this.context.getSystemInfo().isMac()) {
×
84
      return "macosx-universal-64/sonar.sh";
×
85
    }
86
    return "linux-x86-64/sonar.sh";
×
87
  }
88

89
  private void printSonarWebPort() {
90

91
    this.context.info("SonarQube is running at localhost on the following port (default 9000):");
×
92
    Path sonarPropertiesPath = getToolPath().resolve("conf/sonar.properties");
×
93

94
    Properties sonarProperties = this.context.getFileAccess().readProperties(sonarPropertiesPath);
×
95
    String sonarWebPort = sonarProperties.getProperty("sonar.web.port");
×
96
    if (sonarWebPort != null) {
×
97
      this.context.info(sonarWebPort);
×
98
    }
99
  }
×
100
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc