当前位置: 首页>>代码示例>>Java>>正文


Java MessageException.of方法代码示例

本文整理汇总了Java中org.sonar.api.utils.MessageException.of方法的典型用法代码示例。如果您正苦于以下问题:Java MessageException.of方法的具体用法?Java MessageException.of怎么用?Java MessageException.of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.sonar.api.utils.MessageException的用法示例。


在下文中一共展示了MessageException.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: create

import org.sonar.api.utils.MessageException; //导入方法依赖的package包/类
@VisibleForTesting
static PluginInfo create(Path jarPath, PluginManifest manifest) {
  if (StringUtils.isBlank(manifest.getKey())) {
    throw MessageException.of(String.format("File is not a plugin. Please delete it and restart: %s", jarPath.toAbsolutePath()));
  }
  PluginInfo info = new PluginInfo(manifest.getKey());

  info.setJarFile(jarPath.toFile());
  info.setName(manifest.getName());
  info.setMainClass(manifest.getMainClass());
  info.setVersion(Version.create(manifest.getVersion()));

  // optional fields
  info.setUseChildFirstClassLoader(manifest.isUseChildFirstClassLoader());
  info.setBasePlugin(manifest.getBasePlugin());
  info.setImplementationBuild(manifest.getImplementationBuild());
  info.setSonarLintSupported(manifest.isSonarLintSupported());
  String[] requiredPlugins = manifest.getRequirePlugins();
  if (requiredPlugins != null) {
    for (String s : requiredPlugins) {
      info.addRequiredPlugin(RequiredPlugin.parse(s));
    }
  }
  return info;
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:26,代码来源:PluginInfo.java

示例2: language

import org.sonar.api.utils.MessageException; //导入方法依赖的package包/类
@CheckForNull
String language(InputFile inputFile) {
  String detectedLanguage = null;
  for (String languageKey : languagesToConsider) {
    if (isCandidateForLanguage(inputFile, languageKey)) {
      if (detectedLanguage == null) {
        detectedLanguage = languageKey;
      } else {
        // Language was already forced by another pattern
        throw MessageException.of(MessageFormat.format("Language of file ''{0}'' can not be decided as the file matches patterns of both {1} and {2}",
          inputFile.relativePath(), getDetails(detectedLanguage), getDetails(languageKey)));
      }
    }
  }
  if (detectedLanguage != null) {
    LOG.debug("Language of file '{}' is detected to be '{}'", inputFile.absolutePath(), detectedLanguage);
    return detectedLanguage;
  }
  return null;
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:21,代码来源:LanguageDetection.java

示例3: defineRulesForLanguage

import org.sonar.api.utils.MessageException; //导入方法依赖的package包/类
private void defineRulesForLanguage(Context context, String repositoryKey, String repositoryName,
        String languageKey) {
    NewRepository repository = context.createRepository(repositoryKey, languageKey).setName(repositoryName);

    try(InputStream rulesXml = this.getClass().getResourceAsStream(rulesDefinitionFilePath())) {
        if (rulesXml != null) {
            RulesDefinitionXmlLoader rulesLoader = new RulesDefinitionXmlLoader();
            rulesLoader.load(repository, rulesXml, StandardCharsets.UTF_8.name());
            addRemediationCost(repository.rules());
        }
    } catch (IOException e) {
        throw MessageException.of("Unable to load rules defintion", e);
    }

    repository.done();
}
 
开发者ID:sonar-perl,项目名称:sonar-perl,代码行数:17,代码来源:PerlCriticRulesDefinition.java

示例4: init

import org.sonar.api.utils.MessageException; //导入方法依赖的package包/类
public void init(int pullRequestNumber, File projectBaseDir) {
  initGitBaseDir(projectBaseDir);
  try {
    GitHub github;
    if (config.isProxyConnectionEnabled()) {
      github = new GitHubBuilder().withProxy(config.getHttpProxy()).withEndpoint(config.endpoint()).withOAuthToken(config.oauth()).build();
    } else {
      github = new GitHubBuilder().withEndpoint(config.endpoint()).withOAuthToken(config.oauth()).build();
    }
    setGhRepo(github.getRepository(config.repository()));
    setPr(ghRepo.getPullRequest(pullRequestNumber));
    LOG.info("Starting analysis of pull request: " + pr.getHtmlUrl());
    myself = github.getMyself().getLogin();
    loadExistingReviewComments();
    patchPositionMappingByFile = mapPatchPositionsToLines(pr);
  } catch (IOException e) {
    LOG.debug("Unable to perform GitHub WS operation", e);
    throw MessageException.of("Unable to perform GitHub WS operation: " + e.getMessage());
  }
}
 
开发者ID:SonarSource,项目名称:sonar-github,代码行数:21,代码来源:PullRequestFacade.java

示例5: validateRule

import org.sonar.api.utils.MessageException; //导入方法依赖的package包/类
private DefaultRule validateRule(Issue issue) {
  RuleKey ruleKey = issue.ruleKey();
  Rule rule = rules.find(ruleKey);
  if (rule == null) {
    throw MessageException.of(String.format("The rule '%s' does not exist.", ruleKey));
  }
  if (Strings.isNullOrEmpty(rule.name()) && Strings.isNullOrEmpty(issue.primaryLocation().message())) {
    throw MessageException.of(String.format("The rule '%s' has no name and the related issue has no message.", ruleKey));
  }
  return (DefaultRule) rule;
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:12,代码来源:DefaultSensorStorage.java

示例6: getCostByRule

import org.sonar.api.utils.MessageException; //导入方法依赖的package包/类
private static Map<String, String> getCostByRule() {
    Map<String, String> result = new HashMap<>();

    try (InputStream stream = PerlCriticRulesDefinition.class.getResourceAsStream(COST_FILE_CSV);
            Stream< String>lines = new BufferedReader(new InputStreamReader(stream)).lines()) {
        lines //
                .skip(1) // header line
                .forEach(line -> PerlCriticRulesDefinition.completeCost(line, result));
    } catch (IOException e) {
        throw MessageException.of("Unable to load rules remediation function/factor", e);
    }
    return result;
}
 
开发者ID:sonar-perl,项目名称:sonar-perl,代码行数:14,代码来源:PerlCriticRulesDefinition.java

示例7: notificationCommitStatus

import org.sonar.api.utils.MessageException; //导入方法依赖的package包/类
private void notificationCommitStatus(String status, String message) {
    if ("failed".equals(status)) {
        throw MessageException.of(message);
    } else {
        LOG.info(message);
    }
}
 
开发者ID:gabrie-allaigre,项目名称:sonar-gitlab-plugin,代码行数:8,代码来源:CommitIssuePostJob.java

示例8: buildFreemarkerComment

import org.sonar.api.utils.MessageException; //导入方法依赖的package包/类
private String buildFreemarkerComment() {
    Configuration cfg = new Configuration(Configuration.getVersion());
    cfg.setDefaultEncoding("UTF-8");
    cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
    cfg.setLogTemplateExceptions(false);

    try (StringWriter sw = new StringWriter()) {
        new Template(templateName, template, cfg).process(createContext(), sw);
        return StringEscapeUtils.unescapeHtml4(sw.toString());
    } catch (IOException | TemplateException e) {
        LOG.error("Failed to create template {}", templateName, e);
        throw MessageException.of("Failed to create template " + templateName);
    }
}
 
开发者ID:gabrie-allaigre,项目名称:sonar-gitlab-plugin,代码行数:15,代码来源:AbstractCommentBuilder.java

示例9: repository

import org.sonar.api.utils.MessageException; //导入方法依赖的package包/类
public String repository() {
  if (settings.hasKey(GitHubPlugin.GITHUB_REPO)) {
    return repoFromProp();
  }
  if (isNotBlank(settings.getString(CoreProperties.LINKS_SOURCES_DEV)) || isNotBlank(settings.getString(CoreProperties.LINKS_SOURCES))) {
    return repoFromScmProps();
  }
  throw MessageException.of("Unable to determine GitHub repository name for this project. Please provide it using property '" + GitHubPlugin.GITHUB_REPO
    + "' or configure property '" + CoreProperties.LINKS_SOURCES + "'.");
}
 
开发者ID:SonarSource,项目名称:sonar-github,代码行数:11,代码来源:GitHubPluginConfiguration.java

示例10: getVerifiedRepositoryBuilder

import org.sonar.api.utils.MessageException; //导入方法依赖的package包/类
static RepositoryBuilder getVerifiedRepositoryBuilder(Path basedir) {
  RepositoryBuilder builder = new RepositoryBuilder()
    .findGitDir(basedir.toFile())
    .setMustExist(true);

  if (builder.getGitDir() == null) {
    throw MessageException.of("Not inside a Git work tree: " + basedir);
  }
  return builder;
}
 
开发者ID:SonarSource,项目名称:sonar-scm-git,代码行数:11,代码来源:GitScmProvider.java

示例11: privateKey

import org.sonar.api.utils.MessageException; //导入方法依赖的package包/类
@CheckForNull
public File privateKey() {
  if (settings.hasKey(PRIVATE_KEY_PATH_PROP_KEY)) {
    File privateKeyFile = new File(settings.getString(PRIVATE_KEY_PATH_PROP_KEY));
    if (!privateKeyFile.exists() || !privateKeyFile.isFile() || !privateKeyFile.canRead()) {
      throw MessageException.of("Unable to read private key from '" + privateKeyFile + "'");
    }
    return privateKeyFile;
  }
  return null;
}
 
开发者ID:SonarSource,项目名称:sonar-scm-svn,代码行数:12,代码来源:SvnConfiguration.java

示例12: IssuesChecker

import org.sonar.api.utils.MessageException; //导入方法依赖的package包/类
public IssuesChecker(Settings settings, RulesProfile profile) {
  oldDumpFile = getFile(settings, LITSPlugin.OLD_DUMP_PROPERTY);
  newDumpFile = getFile(settings, LITSPlugin.NEW_DUMP_PROPERTY);
  differencesFile = getFile(settings, LITSPlugin.DIFFERENCES_PROPERTY);
  for (ActiveRule activeRule : profile.getActiveRules()) {
    if (!activeRule.getSeverity().toString().equals(Severity.INFO)) {
      throw MessageException.of("Rule '" + activeRule.getRepositoryKey() + ":" + activeRule.getRuleKey() + "' must be declared with severity INFO");
    }
  }
}
 
开发者ID:SonarSource,项目名称:sonar-lits,代码行数:11,代码来源:IssuesChecker.java

示例13: getFile

import org.sonar.api.utils.MessageException; //导入方法依赖的package包/类
private static File getFile(Settings settings, String property) {
  String path = settings.getString(property);
  if (path == null) {
    throw MessageException.of("Missing property '" + property + "'");
  }
  File file = new File(path);
  if (!file.isAbsolute()) {
    throw MessageException.of("Path must be absolute - check property '" + property + "'" );
  }
  return file;
}
 
开发者ID:SonarSource,项目名称:sonar-lits,代码行数:12,代码来源:IssuesChecker.java

示例14: checkMode

import org.sonar.api.utils.MessageException; //导入方法依赖的package包/类
private void checkMode() {
    if (!mode.isIssues()) {
        throw MessageException.of("The GitLab plugin is only intended to be used in preview or issues mode. Please set '" + CoreProperties.ANALYSIS_MODE + "'.");
    }
}
 
开发者ID:gabrie-allaigre,项目名称:sonar-gitlab-plugin,代码行数:6,代码来源:CommitProjectBuilder.java

示例15: checkMode

import org.sonar.api.utils.MessageException; //导入方法依赖的package包/类
private void checkMode() {
  if (!mode.isIssues()) {
    throw MessageException.of("The GitHub plugin is only intended to be used in preview or issues mode. Please set '" + CoreProperties.ANALYSIS_MODE + "'.");
  }

}
 
开发者ID:SonarSource,项目名称:sonar-github,代码行数:7,代码来源:PullRequestProjectBuilder.java


注:本文中的org.sonar.api.utils.MessageException.of方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。