@eagleoutice/flowr-dev
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
48 lines • 2.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SOFTWARE_HAS_TESTS = void 0;
const linter_format_1 = require("../linter-format");
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
const range_1 = require("../../util/range");
const linter_tags_1 = require("../linter-tags");
const flowr_file_1 = require("../../project/context/flowr-file");
exports.SOFTWARE_HAS_TESTS = {
createSearch: (config) => flowr_search_builder_1.Q.fromQuery({
type: 'dependencies',
enabledCategories: ['test'],
...(config.additionalTestFunctions.length > 0 ? { testFunctions: config.additionalTestFunctions } : {})
}),
processSearchResult: (elements, _config, data) => {
const ctx = data.inspectContext();
const testFiles = ctx.files.getFilesByRole(flowr_file_1.FileRole.Test);
const testCalls = elements.getElements().length;
const hasTests = testFiles.length > 0 || testCalls > 0;
const results = hasTests ? [] : [{
certainty: linter_format_1.LintingResultCertainty.Certain,
involvedId: undefined,
loc: range_1.SourceLocation.invalid(),
message: 'No tests found in the project'
}];
return {
results,
'.meta': {
testFilesFound: testFiles.length,
testCallsFound: testCalls
}
};
},
prettyPrint: {
[linter_format_1.LintingPrettyPrintContext.Query]: (result) => result.message,
[linter_format_1.LintingPrettyPrintContext.Full]: (result) => result.message
},
info: {
name: 'Software Has Tests',
description: 'Checks whether the software project has tests (test files in a test directory or test function calls in R code).',
tags: [linter_tags_1.LintingRuleTag.Usability, linter_tags_1.LintingRuleTag.Reproducibility],
certainty: linter_format_1.LintingRuleCertainty.BestEffort,
defaultConfig: {
additionalTestFunctions: []
}
}
};
//# sourceMappingURL=software-has-tests.js.map