Package org.intellij.sonar.sonarserver

Examples of org.intellij.sonar.sonarserver.Rule


    // try to get desc from already fetched rules
    final Optional<SonarRules> sonarRules = SonarRules.getInstance(project);
    if (sonarRules.isPresent()) {
      final SonarRules sonarRulesState = sonarRules.get().getState();
      if (sonarRulesState != null) {
        final Rule rule = sonarRulesState.getSonarRulesByRuleKey().get(issue.get().getRuleKey());
        if (rule != null && !rule.isEmpty()) return rule.getDesc();
      }
    }

    // fetch and persist rule
    Settings settings;
    final Module moduleForFile = ModuleUtil.findModuleForFile(psiFile.getVirtualFile(), project);
    if (moduleForFile != null) {
      settings = ModuleSettings.getInstance(moduleForFile).getState();
      settings = SettingsUtil.process(project, settings);
    } else {
      settings = ProjectSettings.getInstance(project).getState();
    }
    if (settings == null) return null;

    final String serverName = settings.getServerName();
    final Optional<SonarServerConfig> serverConfig = SonarServers.get(serverName);
    if (!serverConfig.isPresent()) return null;
    final SonarServer sonarServer = SonarServer.create(serverConfig.get());
    final Rule rule = sonarServer.getRule(issue.get().getRuleKey());

    // persist rule
    if (sonarRules.isPresent()) {
      final SonarRules sonarRulesState = sonarRules.get().getState();
      if (sonarRulesState!= null && !rule.isEmpty()) {
        sonarRulesState.getSonarRulesByRuleKey().put(issue.get().getRuleKey(), rule);
      }
    }

    return rule.getDesc();
  }
View Full Code Here

TOP

Related Classes of org.intellij.sonar.sonarserver.Rule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.