Java Code Examples for org.sonar.squidbridge.api.SourceFile#getDouble()

The following examples show how to use org.sonar.squidbridge.api.SourceFile#getDouble() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlowLinesOfCodeVisitorTest.java    From sonar-flow-plugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void linesOfCodeTest() {
  logger.debug("Scanning file");
  List<SquidAstVisitor<Grammar>> metrics = new ArrayList<SquidAstVisitor<Grammar>>();
  List<FlowCheck> checks = new ArrayList<FlowCheck>();

  SourceFile sfCorrect = FlowAstScanner.scanSingleFile(new File(
      "src/test/resources/WmTestPackage/ns/I8cFlowSonarPluginTest"
      + "/pub/checkLinesOfCode/flow.xml"),
      checks, metrics);
  int lines = (int) sfCorrect.getDouble(FlowMetric.LINES_OF_CODE);
  assertEquals(13, lines);
}
 
Example 2
Source File: FlowCommentLinesVisitorTest.java    From sonar-flow-plugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void commentLinesTest() {
  logger.debug("Scanning file");
  List<SquidAstVisitor<Grammar>> metrics = new ArrayList<SquidAstVisitor<Grammar>>();
  List<FlowCheck> checks = new ArrayList<FlowCheck>();

  SourceFile sfCorrect = FlowAstScanner.scanSingleFile(new File(
      "src/test/resources/WmTestPackage/ns/I8cFlowSonarPluginTest"
      + "/pub/commentLinesVisitor/flow.xml"),
      checks, metrics);
  int lines = (int) sfCorrect.getDouble(FlowMetric.COMMENT_LINES);
  assertEquals(2, lines);
}
 
Example 3
Source File: FlowCommentLinesVisitorTest.java    From sonar-flow-plugin with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void commentLinesTest2() {
  logger.debug("Scanning file");
  List<SquidAstVisitor<Grammar>> metrics = new ArrayList<SquidAstVisitor<Grammar>>();
  metrics.add(new FlowCommentLinesVisitor<Grammar>(FlowMetric.COMMENT_LINES));
  List<FlowCheck> checks = new ArrayList<FlowCheck>();

  SourceFile sfCorrect = FlowAstScanner.scanSingleFile(new File(
      "src/test/resources/WmTestPackage/ns/I8cFlowSonarPluginTest"
      + "/pub/commentLinesVisitor2/flow.xml"),
      checks, metrics);
  int lines = (int) sfCorrect.getDouble(FlowMetric.COMMENT_LINES);
  assertEquals(0, lines);
}