• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SonarException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



SonarException类属于org.sonar.api.utils包,在下文中一共展示了SonarException类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: addRuleProperty

import org.sonar.api.utils.SonarException; //导入依赖的package包/类
private static void addRuleProperty(Rule rule, Field field) {
  org.sonar.check.RuleProperty propertyAnnotation = field.getAnnotation(org.sonar.check.RuleProperty.class);
  if (propertyAnnotation != null) {
    String fieldKey = StringUtils.defaultIfEmpty(propertyAnnotation.key(), field.getName());
    RuleParam param = rule.createParameter(fieldKey);
    param.setDescription(propertyAnnotation.description());
    param.setDefaultValue(propertyAnnotation.defaultValue());
    if (!StringUtils.isBlank(propertyAnnotation.type())) {
      try {
        param.setType(PropertyType.valueOf(propertyAnnotation.type().trim()).name());
      } catch (IllegalArgumentException e) {
        throw new SonarException("Invalid property type [" + propertyAnnotation.type() + "]", e);
      }
    } else {
      param.setType(guessType(field.getType()).name());
    }
  }
}
 
开发者ID:Asqatasun,项目名称:Asqatasun-Sonar-Plugin,代码行数:19,代码来源:RuleRepositoryHelper.java


示例2: visitFile

import org.sonar.api.utils.SonarException; //导入依赖的package包/类
@Override
public void visitFile(@Nullable AstNode astNode) {
  List<String> lines;
  try {
    lines = Files.readLines(getContext().getFile(), charset);
  } catch (IOException e) {
    throw new SonarException(e);
  }
  for (int i = 0; i < lines.size(); i++) {
    String line = lines.get(i);
    if (line.length() > maximumLineLength) {
      addIssue(
        i + 1,
        this,
        MessageFormat.format(
          "The line contains {0,number,integer} characters which is greater than {1,number,integer} authorized.",
          line.length(),
          maximumLineLength));
    }
  }
}
 
开发者ID:iwarapter,项目名称:sonar-puppet,代码行数:22,代码来源:LineLengthCheck.java


示例3: sonarSeverityToJiraPriorityId

import org.sonar.api.utils.SonarException; //导入依赖的package包/类
protected String sonarSeverityToJiraPriorityId(RulePriority reviewSeverity, Settings settings) {
  final String priorityId;
  switch (reviewSeverity) {
    case INFO:
      priorityId = settings.getString(JiraConstants.JIRA_INFO_PRIORITY_ID);
      break;
    case MINOR:
      priorityId = settings.getString(JiraConstants.JIRA_MINOR_PRIORITY_ID);
      break;
    case MAJOR:
      priorityId = settings.getString(JiraConstants.JIRA_MAJOR_PRIORITY_ID);
      break;
    case CRITICAL:
      priorityId = settings.getString(JiraConstants.JIRA_CRITICAL_PRIORITY_ID);
      break;
    case BLOCKER:
      priorityId = settings.getString(JiraConstants.JIRA_BLOCKER_PRIORITY_ID);
      break;
    default:
      throw new SonarException("Unable to convert review severity to JIRA priority: " + reviewSeverity);
  }
  return priorityId;
}
 
开发者ID:aifraenkel,项目名称:caltec-tools,代码行数:24,代码来源:JiraIssueCreator.java


示例4: visitFile

import org.sonar.api.utils.SonarException; //导入依赖的package包/类
@Override
public void visitFile(AstNode astNode) {
  List<String> lines;
  try {
    lines = Files.readLines(getContext().getFile(), charset);
  } catch (IOException e) {
    throw new SonarException(e);
  }
  for (String line : lines) {
    if (line.contains("\t")) {
      addIssueOnFile(this, "Replace all tab characters in this file by sequences of whitespaces.");
      break;
    }
  }
}
 
开发者ID:iwarapter,项目名称:sonar-puppet,代码行数:16,代码来源:TabCharacterCheck.java


示例5: visitFile

import org.sonar.api.utils.SonarException; //导入依赖的package包/类
@Override
public void visitFile(AstNode astNode) {
  List<String> lines;
  try {
    lines = Files.readLines(getContext().getFile(), charset);
  } catch (IOException e) {
    throw new SonarException(e);
  }
  for (int i = 0; i < lines.size(); i++) {
    String line = lines.get(i);
    if (line.length() > 0 && Pattern.matches("[" + WHITESPACE + "]", line.subSequence(line.length() - 1, line.length()))) {
      addIssue(i + 1, this, "Remove the useless trailing whitespaces at the end of this line.");
    }
  }
}
 
开发者ID:iwarapter,项目名称:sonar-puppet,代码行数:16,代码来源:TrailingWhitespaceCheck.java


示例6: visitFile

import org.sonar.api.utils.SonarException; //导入依赖的package包/类
@Override
public void visitFile(AstNode astNode) {
  RandomAccessFile randomAccessFile = null;
  try {
    randomAccessFile = new RandomAccessFile(getContext().getFile(), "r");
    if (!endsWithNewline(randomAccessFile)) {
      addIssueOnFile(this, "Add an empty new line at the end of this file.");
    }
  } catch (IOException e) {
    throw new SonarException(e);
  } finally {
    Closeables.closeQuietly(randomAccessFile);
  }
}
 
开发者ID:iwarapter,项目名称:sonar-puppet,代码行数:15,代码来源:MissingNewLineAtEndOfFileCheck.java


示例7: parseFiles

import org.sonar.api.utils.SonarException; //导入依赖的package包/类
private void parseFiles(File[] reports, UnitTestIndex index) {
  SurefireStaxHandler staxParser = new SurefireStaxHandler(index);
  StaxParser parser = new StaxParser(staxParser, false);
  for (File report : reports) {
    try {
      parser.parse(report);
    } catch (XMLStreamException e) {
      throw new SonarException("Fail to parse the Surefire report: " + report, e);
    }
  }
}
 
开发者ID:acwatson,项目名称:sonar-karma-test-report-plugin,代码行数:12,代码来源:AbstractSurefireParser.java


示例8: analyse

import org.sonar.api.utils.SonarException; //导入依赖的package包/类
public final void analyse(SensorContext context) {

    if (noBinaryDirectoryFound()) {
      J3cLogger.LOGGER.info("No JaCoCo analysis of project coverage can be done since there is no directories with classes.");
      return;
    }

    File jacocoExecutionData = pathResolver.relativeFile(fileSystem.baseDir(), configuration.getReportPath());

    if(noCoverageReportFound(jacocoExecutionData)) {
      J3cLogger.LOGGER.info("No JaCoCo analysis of project coverage found at: " + jacocoExecutionData.getPath());
      return;
    }

    try {
      ExecutionDataStore mergedResults = parseExecutionData(jacocoExecutionData);
      CoverageBuilder coverageBuilder = analyze(mergedResults);

      CoverageComplexityDataSet coverageComplexityDataSet = new CoverageComplexityDataSet();
      for (IClassCoverage classCoverage : coverageBuilder.getClasses()) {
        if (isExcluded(classCoverage) || isNotInScope(classCoverage, context)) {
          continue;
        }
        for (IMethodCoverage methodCoverage : classCoverage.getMethods()) {
          coverageComplexityDataSet.add(methodCoverage);
        }
      }
      saveMeasures(context, coverageComplexityDataSet);

    } catch (Exception e) {
      J3cLogger.LOGGER.error(e.getMessage(), e);
      throw new SonarException(e);
    }
  }
 
开发者ID:cezarcoca,项目名称:sonar-j3c,代码行数:35,代码来源:JacocoAnalyzer.java


示例9: visitFile

import org.sonar.api.utils.SonarException; //导入依赖的package包/类
@Override
public void visitFile(AstNode astNode) {
  List<String> lines;
  try {
    lines = Files.readLines(getContext().getFile(), charset);
  } catch (IOException e) {
    throw new SonarException(e);
  }
  for (int i = 0; i < lines.size(); i++) {
    if (lines.get(i).contains("\t")) {
      getContext().createLineViolation(this, "Replace all tab characters in this file by sequences of white-spaces.", i + 1);
      break;
    }
  }
}
 
开发者ID:Ne0s,项目名称:sonar-plsql,代码行数:16,代码来源:TabCharacterCheck.java


示例10: count

import org.sonar.api.utils.SonarException; //导入依赖的package包/类
public void count() {
    logger.fine("Count comment in " + sourceCode.getResource().getLongName());
    
    ArrayList<String> code = (ArrayList<String>) sourceCode.getCode();

    if (code != null && code.size() > 0) {
        try {
            boolean commenting = false;
            for (String line : code) {
                String trimmed = StringUtils.trim(line);
                if (StringUtils.isBlank(trimmed)) {
                    blankLines++;
                } else if (trimmed.startsWith("(:") && trimmed.endsWith(":)")) {
                    commentLines++;
                } else if (trimmed.startsWith("(:") && !trimmed.contains(":)") && !trimmed.endsWith(":)")) {
                    commenting = true;
                    commentLines++;
                } else if (commenting && trimmed.contains(":)")) {
                    commenting = false;
                    commentLines++;
                } else if (commenting) {
                    commentLines++;
                } else {
                    if (trimmed.contains("declare function")) {
                        functions++;
                    }
                }
                
                linesOfCode++;
            }                
        } catch (Exception e) {
            throw new SonarException(e);
        }
    }
            
    sourceCode.addMeasure(CoreMetrics.FUNCTIONS, (double) functions);
    sourceCode.addMeasure(CoreMetrics.LINES, (double) linesOfCode);
    sourceCode.addMeasure(CoreMetrics.COMMENT_LINES, (double) commentLines);
    sourceCode.addMeasure(CoreMetrics.NCLOC, (double) linesOfCode - blankLines - commentLines);        
}
 
开发者ID:malteseduck,项目名称:sonar-xquery-plugin,代码行数:41,代码来源:XQueryLineCountParser.java


示例11: getCode

import org.sonar.api.utils.SonarException; //导入依赖的package包/类
@Override
public List<String> getCode() {
    if (inputFile != null && code.size() == 0) {
        try {
            code = FileUtils.readLines(inputFile, "UTF-8");
            return code;
        } catch (IOException e) {
            throw new SonarException(e);
        }
    } else {
        return code;
    }
}
 
开发者ID:malteseduck,项目名称:sonar-xquery-plugin,代码行数:14,代码来源:XQuerySourceCode.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ErrorReceiverFilter类代码示例发布时间:2022-05-23
下一篇:
Java XMLBufferListener类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap