Java Code Examples for org.sonar.api.batch.fs.InputFile#file()
The following examples show how to use
org.sonar.api.batch.fs.InputFile#file() .
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: GherkinSquidSensor.java From sonar-gherkin-plugin with GNU Lesser General Public License v3.0 | 6 votes |
private List<Issue> scanFile(InputFile inputFile, GherkinDocumentTree gherkinDocument, List<TreeVisitor> visitors) { GherkinVisitorContext context = new GherkinVisitorContext(gherkinDocument, inputFile.file()); List<Issue> issues = new ArrayList<>(); for (TreeVisitor visitor : visitors) { if (visitor instanceof CharsetAwareVisitor) { ((CharsetAwareVisitor) visitor).setCharset(fileSystem.encoding()); } if (visitor instanceof GherkinCheck) { issues.addAll(((GherkinCheck) visitor).scanFile(context)); } else { visitor.scanTree(context); } } return issues; }
Example 2
Source File: AbstractLanguageAnalyzerSensor.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 5 votes |
private List<Issue> scanFile(InputFile inputFile, TreeImpl tree, List<TreeVisitor> visitors) { CssTreeVisitorContext context = new CssTreeVisitorContext(tree, inputFile.file(), language()); List<Issue> issues = new ArrayList<>(); for (TreeVisitor visitor : visitors) { if (visitor instanceof CharsetAwareVisitor) { ((CharsetAwareVisitor) visitor).setCharset(fileSystem.encoding()); } if (visitor instanceof CssCheck) { issues.addAll(((CssCheck) visitor).scanFile(context)); } else { visitor.scanTree(context); } } return issues; }
Example 3
Source File: RubyMetricsSensor.java From sonar-ruby-plugin with MIT License | 5 votes |
private void setMetricsForFile(InputFile inputFile, SensorContext ctx) { try (FileReader fileReader = new FileReader(inputFile.file()); BufferedReader reader = new BufferedReader(fileReader)) { Source source = new Source(reader, new RubyRecognizer(), "#"); ctx.<Integer>newMeasure().forMetric(CoreMetrics.NCLOC).on(inputFile).withValue(source.getMeasure(Metric.LINES_OF_CODE)).save(); ctx.<Integer>newMeasure().forMetric(CoreMetrics.COMMENT_LINES).on(inputFile).withValue(CommentCountParser.countLinesOfComment(inputFile.file())).save(); ctx.<Integer>newMeasure().forMetric(CoreMetrics.CLASSES).on(inputFile).withValue(ClassCountParser.countClasses(inputFile.file())).save(); } catch (IOException e) { LOG.warn("Unable to read ruby file to gather metrics.", e); } }
Example 4
Source File: GherkinSquidSensor.java From sonar-gherkin-plugin with GNU Lesser General Public License v3.0 | 5 votes |
private String getFileLanguage(InputFile inputFile) { try (BufferedReader br = new BufferedReader(new FileReader(inputFile.file()))) { Matcher matcher = GherkinDialectProvider.LANGUAGE_DECLARATION_PATTERN.matcher(br.readLine()); if (matcher.find()) { return matcher.group(1); } else { return GherkinDialectProvider.DEFAULT_LANGUAGE; } } catch (IOException e) { throw new IllegalStateException("Cannot determine language of file " + inputFile.absolutePath(), e); } }
Example 5
Source File: LOCSensorImpl.java From SonarTsPlugin with MIT License | 4 votes |
private BufferedReader getReaderFromFile(InputFile inputFile) throws FileNotFoundException { return new BufferedReader(new FileReader(inputFile.file())); }