private void processFileMeasures(InputComponent component, File measureFile, SensorContext context) { if (measureFile.exists()) { LOG.debug("Processing " + measureFile.getAbsolutePath()); try { List<String> lines = FileUtils.readLines(measureFile, context.fileSystem().encoding().name()); int lineNumber = 0; for (String line : lines) { lineNumber++; if (StringUtils.isBlank(line) || line.startsWith("#")) { continue; } processMeasure(component, context, measureFile, lineNumber, line); } } catch (IOException e) { throw new IllegalStateException(e); } } }
private void processFileError(InputFile inputFile, SensorContext context) { Path ioFile = inputFile.file().toPath(); Path errorFile = ioFile.resolveSibling(ioFile.getFileName() + ERROR_EXTENSION).toAbsolutePath(); if (Files.exists(errorFile) && Files.isRegularFile(errorFile)) { LOG.debug("Processing " + errorFile.toString()); try { List<String> lines = Files.readAllLines(errorFile, context.fileSystem().encoding()); for (String line : lines) { if (StringUtils.isBlank(line) || line.startsWith("#")) { continue; } processLine(line, inputFile, context); } } catch (IOException e) { throw new IllegalStateException(e); } } }
private void processFileMeasures(InputFile inputFile, SensorContext context) { File ioFile = inputFile.file(); File measureFile = new File(ioFile.getParentFile(), ioFile.getName() + MEASURES_EXTENSION); if (measureFile.exists()) { LOG.debug("Processing " + measureFile.getAbsolutePath()); try { FileLinesContext linesContext = contextFactory.createFor(inputFile); List<String> lines = FileUtils.readLines(measureFile, context.fileSystem().encoding().name()); int lineNumber = 0; for (String line : lines) { lineNumber++; if (StringUtils.isBlank(line) || line.startsWith("#")) { continue; } processMeasure(linesContext, measureFile, lineNumber, line); } linesContext.save(); } catch (IOException e) { throw new IllegalStateException(e); } } }
private void processFileSymbol(InputFile inputFile, SensorContext context) { File ioFile = inputFile.file(); File symbolFile = new File(ioFile.getParentFile(), ioFile.getName() + SYMBOL_EXTENSION); if (symbolFile.exists()) { LOG.debug("Processing " + symbolFile.getAbsolutePath()); try { List<String> lines = FileUtils.readLines(symbolFile, context.fileSystem().encoding().name()); int lineNumber = 0; NewSymbolTable symbolTable = context.newSymbolTable() .onFile(inputFile); for (String line : lines) { lineNumber++; if (StringUtils.isBlank(line) || line.startsWith("#")) { continue; } processLine(symbolFile, lineNumber, symbolTable, line); } symbolTable.save(); } catch (IOException e) { throw new IllegalStateException(e); } } }
private void processFileHighlighting(InputFile inputFile, SensorContext context) { File ioFile = inputFile.file(); File highlightingFile = new File(ioFile.getParentFile(), ioFile.getName() + HIGHLIGHTING_EXTENSION); if (highlightingFile.exists()) { LOG.debug("Processing " + highlightingFile.getAbsolutePath()); try { List<String> lines = FileUtils.readLines(highlightingFile, context.fileSystem().encoding().name()); int lineNumber = 0; NewHighlighting highlighting = context.newHighlighting() .onFile(inputFile); for (String line : lines) { lineNumber++; if (StringUtils.isBlank(line) || line.startsWith("#")) { continue; } processLine(highlightingFile, lineNumber, highlighting, line); } highlighting.save(); } catch (IOException e) { throw new IllegalStateException(e); } } }
private void processSignificantCodeFile(InputFile inputFile, SensorContext context) { Path ioFile = inputFile.path(); Path significantCodeFile = ioFile.resolveSibling(ioFile.getFileName() + FILE_EXTENSION).toAbsolutePath(); if (Files.exists(significantCodeFile) && Files.isRegularFile(significantCodeFile)) { LOG.debug("Processing " + significantCodeFile.toString()); try { List<String> lines = Files.readAllLines(significantCodeFile, context.fileSystem().encoding()); NewSignificantCode significantCode = context.newSignificantCode() .onFile(inputFile); for (String line : lines) { if (StringUtils.isBlank(line) || line.startsWith("#")) { continue; } processLine(line, inputFile, significantCode); } significantCode.save(); } catch (IOException e) { throw new IllegalStateException(e); } } }
LOG.debug("Processing " + testExecutionFile.getAbsolutePath()); try { List<String> lines = FileUtils.readLines(testExecutionFile, fs.encoding().name()); int lineNumber = 0; MutableTestPlan testPlan = perspectives.as(MutableTestPlan.class, inputFile);
LOG.debug("Processing " + testExecutionFile.getAbsolutePath()); try { List<String> lines = FileUtils.readLines(testExecutionFile, fs.encoding().name()); int lineNumber = 0; MutableTestPlan testPlan = perspectives.as(MutableTestPlan.class, inputFile);
LOG.debug("Processing " + coverageFile.getAbsolutePath()); try { List<String> lines = FileUtils.readLines(coverageFile, context.fileSystem().encoding().name()); NewCoverage coverageBuilder = context.newCoverage() .onFile(inputFile)
/** * Default constructor to initialize the variables. * * @param language * @param fileSystem */ public ApexCpdMapping(Apex language, FileSystem fileSystem) { this.language = language; this.charset = fileSystem.encoding(); }
/** * Returns the apex configuration. * * @return the configuration. */ private ApexConfiguration createConfiguration() { return new ApexConfiguration(fileSystem.encoding()); }
private JavaConfiguration createConfiguration() { boolean analyzePropertyAccessors = settings.getBoolean(JavaPlugin.SQUID_ANALYSE_ACCESSORS_PROPERTY); Charset charset = fs.encoding(); JavaConfiguration conf = new JavaConfiguration(charset); conf.setSeparateAccessorsFromMethods(analyzePropertyAccessors); return conf; }
public PerlScanner(SensorContext context, List<InputFile> inputFiles) { this.context = context; this.inputFiles = inputFiles; this.parser = PerlParser.create(new PerlConfiguration(context.fileSystem().encoding())); }
public PlSqlAstScanner(SensorContext context, Collection<PlSqlVisitor> checks, NoSonarFilter noSonarFilter, FormsMetadata formsMetadata, boolean isErrorRecoveryEnabled, FileLinesContextFactory fileLinesContextFactory) { this.context = context; this.checks = checks; this.noSonarFilter = noSonarFilter; this.formsMetadata = formsMetadata; this.fileLinesContextFactory = fileLinesContextFactory; this.parser = PlSqlParser.create(new PlSqlConfiguration(context.fileSystem().encoding(), isErrorRecoveryEnabled)); }
public PythonScanner(SensorContext context, Checks<PythonCheck> checks, FileLinesContextFactory fileLinesContextFactory, NoSonarFilter noSonarFilter, List<InputFile> inputFiles) { this.context = context; this.checks = checks; this.fileLinesContextFactory = fileLinesContextFactory; this.noSonarFilter = noSonarFilter; this.cpdAnalyzer = new PythonCpdAnalyzer(context); this.inputFiles = inputFiles; this.parser = PythonParser.create(new PythonConfiguration(context.fileSystem().encoding())); }
public PythonScanner(SensorContext context, Checks<PythonCheck> checks, FileLinesContextFactory fileLinesContextFactory, NoSonarFilter noSonarFilter, List<InputFile> inputFiles) { this.context = context; this.checks = checks; this.fileLinesContextFactory = fileLinesContextFactory; this.noSonarFilter = noSonarFilter; this.cpdAnalyzer = new PythonCpdAnalyzer(context); this.inputFiles = inputFiles; this.parser = PythonParser.create(new PythonConfiguration(context.fileSystem().encoding())); }
private void populateIndex(String languageKey, List<InputFile> sourceFiles, CpdMapping mapping, SonarDuplicationsIndex index) { TokenizerBridge bridge = new TokenizerBridge(mapping.getTokenizer(), fs.encoding().name(), getBlockSize(languageKey)); for (InputFile inputFile : sourceFiles) { LOG.debug("Populating index from {}", inputFile); String resourceEffectiveKey = ((DeprecatedDefaultInputFile) inputFile).key(); List<Block> blocks2 = bridge.chunk(resourceEffectiveKey, inputFile.file()); index.insert(inputFile, blocks2); } }
private void populateIndex(String languageKey, List<InputFile> sourceFiles, CpdMapping mapping, SonarDuplicationsIndex index) { TokenizerBridge bridge = new TokenizerBridge(mapping.getTokenizer(), fs.encoding().name(), getBlockSize(languageKey)); for (InputFile inputFile : sourceFiles) { LOG.debug("Populating index from {}", inputFile); String resourceEffectiveKey = ((DefaultInputFile) inputFile).key(); List<Block> blocks = bridge.chunk(resourceEffectiveKey, inputFile.file()); index.insert(inputFile, blocks); } }
private void analyzeFile(SensorContext context, InputFile file, File out) throws IOException { FileSystem fileSystem = context.fileSystem(); List<Issue> issues = analyzer.analyze(file.absolutePath(), fileSystem.encoding(), out); for (Issue pylintIssue : issues) { ActiveRule rule = context.activeRules().find(RuleKey.of(PylintRuleRepository.REPOSITORY_KEY, pylintIssue.getRuleId())); PylintImportSensor.processRule(pylintIssue, file, rule, context); } }
private void analyzeFile(SensorContext context, InputFile file, File out) throws IOException { FileSystem fileSystem = context.fileSystem(); String pylintConfigPath = conf.getPylintConfigPath(fileSystem); String pylintPath = conf.getPylintPath(); PylintIssuesAnalyzer analyzer = new PylintIssuesAnalyzer(pylintPath, pylintConfigPath); List<Issue> issues = analyzer.analyze(file.absolutePath(), fileSystem.encoding(), out); for (Issue pylintIssue : issues) { ActiveRule rule = context.activeRules().find(RuleKey.of(PylintRuleRepository.REPOSITORY_KEY, pylintIssue.getRuleId())); PylintImportSensor.processRule(pylintIssue, file, rule, context); } }