@eagleoutice/flowr-dev
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
46 lines • 2.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SOFTWARE_HAS_LICENSE = 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");
const flowr_description_file_1 = require("../../project/plugins/file-plugins/files/flowr-description-file");
exports.SOFTWARE_HAS_LICENSE = {
createSearch: () => flowr_search_builder_1.Q.fromQuery({ type: 'dependencies', enabledCategories: [] }),
processSearchResult: (_elements, config, data) => {
const ctx = data.inspectContext();
const licenseFiles = ctx.files.getFilesByRole(flowr_file_1.FileRole.License);
let hasLicense = licenseFiles.length > 0;
if (!hasLicense && config.checkDescriptionFile) {
for (const f of ctx.files.getFilesByRole(flowr_file_1.FileRole.Description)) {
if (flowr_description_file_1.FlowrDescriptionFile.from(f).license()) {
hasLicense = true;
break;
}
}
}
const results = hasLicense ? [] : [{
certainty: linter_format_1.LintingResultCertainty.Certain,
involvedId: undefined,
loc: range_1.SourceLocation.invalid(),
message: 'No license found in the project'
}];
return { results, '.meta': {} };
},
prettyPrint: {
[linter_format_1.LintingPrettyPrintContext.Query]: (result) => result.message,
[linter_format_1.LintingPrettyPrintContext.Full]: (result) => result.message
},
info: {
name: 'Software Has License',
description: 'Checks whether the software project provides a license (via a LICENSE file or the DESCRIPTION file License field).',
tags: [linter_tags_1.LintingRuleTag.Documentation, linter_tags_1.LintingRuleTag.Usability],
certainty: linter_format_1.LintingRuleCertainty.BestEffort,
defaultConfig: {
checkDescriptionFile: true
}
}
};
//# sourceMappingURL=software-has-license.js.map