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

devonfw / IDEasy / 9808498015

05 Jul 2024 12:43PM UTC coverage: 61.798% (+0.6%) from 61.159%
9808498015

push

github

web-flow
#25: implement tool commandlet for intellij (#447)

1983 of 3531 branches covered (56.16%)

Branch coverage included in aggregate %.

5264 of 8196 relevant lines covered (64.23%)

2.82 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.Properties;
5
import java.util.Set;
6

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

15
public class Sonar extends LocalToolCommandlet {
16

17
  public final EnumProperty<SonarCommand> command;
18

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

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

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

32
  @Override
33
  protected void initProperties() {
34

35
    // Empty on purpose
36
  }
1✔
37

38
  @Override
39
  public boolean install(boolean silent) {
40

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

45
  @Override
46
  public void run() {
47

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

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

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

72
  @Override
73
  protected String getBinaryName() {
74

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

88
  private void printSonarWebPort() {
89

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

93
    Properties sonarProperties = PropertiesFileUtil.loadProperties(sonarPropertiesPath);
×
94
    String sonarWebPort = sonarProperties.getProperty("sonar.web.port");
×
95
    if (sonarWebPort != null) {
×
96
      this.context.info(sonarWebPort);
×
97
    }
98
  }
×
99
}
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