@eagleoutice/flowr 2.3.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -30
- package/abstract-interpretation/data-frame/absint-visitor.d.ts +2 -3
- package/abstract-interpretation/data-frame/absint-visitor.js +14 -16
- package/abstract-interpretation/data-frame/mappers/function-mapper.js +3 -3
- package/abstract-interpretation/data-frame/semantics.d.ts +1 -1
- package/abstract-interpretation/data-frame/semantics.js +7 -10
- package/abstract-interpretation/data-frame/shape-inference.js +2 -8
- package/benchmark/slicer.js +7 -5
- package/benchmark/stats/size-of.js +3 -3
- package/benchmark/summarizer/second-phase/graph.js +1 -1
- package/benchmark/summarizer/second-phase/process.js +1 -1
- package/cli/benchmark-app.d.ts +1 -0
- package/cli/benchmark-app.js +1 -0
- package/cli/benchmark-helper-app.d.ts +1 -0
- package/cli/benchmark-helper-app.js +4 -3
- package/cli/common/options.js +2 -0
- package/cli/repl/commands/repl-query.js +1 -1
- package/cli/repl/server/connection.js +14 -5
- package/control-flow/basic-cfg-guided-visitor.d.ts +1 -2
- package/control-flow/basic-cfg-guided-visitor.js +0 -6
- package/control-flow/cfg-simplification.d.ts +6 -0
- package/control-flow/cfg-simplification.js +18 -9
- package/control-flow/control-flow-graph.d.ts +2 -8
- package/control-flow/control-flow-graph.js +1 -6
- package/control-flow/extract-cfg.d.ts +2 -2
- package/control-flow/extract-cfg.js +52 -63
- package/core/pipeline-executor.js +0 -8
- package/core/steps/all/static-slicing/00-slice.d.ts +7 -1
- package/core/steps/all/static-slicing/00-slice.js +9 -3
- package/core/steps/pipeline/default-pipelines.d.ts +74 -74
- package/dataflow/environments/append.js +1 -1
- package/dataflow/environments/built-in-config.d.ts +12 -4
- package/dataflow/environments/built-in-config.js +23 -82
- package/dataflow/environments/built-in.d.ts +40 -6
- package/dataflow/environments/built-in.js +119 -23
- package/dataflow/environments/clone.d.ts +3 -2
- package/dataflow/environments/clone.js +6 -5
- package/dataflow/environments/define.js +1 -2
- package/dataflow/environments/diff.js +1 -3
- package/dataflow/environments/environment.d.ts +18 -24
- package/dataflow/environments/environment.js +25 -37
- package/dataflow/environments/overwrite.d.ts +1 -1
- package/dataflow/environments/overwrite.js +1 -1
- package/dataflow/environments/remove.d.ts +2 -2
- package/dataflow/environments/remove.js +3 -4
- package/dataflow/environments/resolve-by-name.d.ts +3 -3
- package/dataflow/environments/resolve-by-name.js +4 -5
- package/dataflow/eval/resolve/alias-tracking.d.ts +12 -12
- package/dataflow/eval/resolve/alias-tracking.js +12 -12
- package/dataflow/eval/resolve/resolve.js +1 -1
- package/dataflow/extractor.js +6 -1
- package/dataflow/graph/dataflowgraph-builder.d.ts +3 -1
- package/dataflow/graph/dataflowgraph-builder.js +2 -2
- package/dataflow/graph/graph.d.ts +2 -1
- package/dataflow/graph/graph.js +6 -2
- package/dataflow/graph/invert-dfg.d.ts +2 -0
- package/dataflow/graph/invert-dfg.js +17 -0
- package/dataflow/info.d.ts +1 -1
- package/dataflow/internal/linker.js +9 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +3 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +5 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +9 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +1 -1
- package/dataflow/processor.d.ts +5 -1
- package/documentation/doc-util/doc-env.js +1 -2
- package/documentation/doc-util/doc-query.js +1 -1
- package/documentation/doc-util/doc-search.js +2 -2
- package/documentation/print-cfg-wiki.js +3 -4
- package/documentation/print-core-wiki.js +2 -2
- package/documentation/print-dataflow-graph-wiki.js +7 -0
- package/documentation/print-faq-wiki.js +4 -0
- package/documentation/print-linter-wiki.js +32 -4
- package/documentation/print-linting-and-testing-wiki.js +13 -1
- package/documentation/print-onboarding-wiki.js +4 -0
- package/documentation/print-query-wiki.js +12 -3
- package/linter/linter-executor.js +1 -2
- package/linter/linter-format.d.ts +26 -4
- package/linter/linter-format.js +25 -6
- package/linter/linter-rules.d.ts +40 -12
- package/linter/linter-rules.js +3 -1
- package/linter/rules/absolute-path.d.ts +4 -7
- package/linter/rules/absolute-path.js +9 -6
- package/linter/rules/dataframe-access-validation.d.ts +3 -1
- package/linter/rules/dataframe-access-validation.js +3 -1
- package/linter/rules/dead-code.d.ts +43 -0
- package/linter/rules/dead-code.js +50 -0
- package/linter/rules/deprecated-functions.d.ts +3 -2
- package/linter/rules/deprecated-functions.js +3 -1
- package/linter/rules/file-path-validity.d.ts +4 -4
- package/linter/rules/file-path-validity.js +8 -6
- package/linter/rules/naming-convention.d.ts +4 -3
- package/linter/rules/naming-convention.js +3 -1
- package/linter/rules/seeded-randomness.d.ts +4 -3
- package/linter/rules/seeded-randomness.js +3 -1
- package/linter/rules/unused-definition.d.ts +2 -0
- package/linter/rules/unused-definition.js +3 -1
- package/package.json +1 -1
- package/queries/base-query-format.d.ts +2 -0
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +7 -7
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +24 -1
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +9 -5
- package/queries/catalog/dependencies-query/function-info/read-functions.js +5 -2
- package/queries/catalog/dependencies-query/function-info/write-functions.js +6 -0
- package/queries/catalog/linter-query/linter-query-format.js +1 -1
- package/queries/catalog/location-map-query/location-map-query-executor.js +7 -5
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +3 -0
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -0
- package/queries/catalog/search-query/search-query-executor.js +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +3 -2
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +3 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.js +3 -1
- package/queries/query-print.d.ts +1 -1
- package/queries/query-print.js +0 -1
- package/queries/query.d.ts +16 -5
- package/queries/query.js +24 -11
- package/search/flowr-search-builder.d.ts +6 -6
- package/search/flowr-search-executor.d.ts +2 -2
- package/search/flowr-search-executor.js +1 -1
- package/search/flowr-search.d.ts +13 -8
- package/search/flowr-search.js +21 -0
- package/search/search-executor/search-enrichers.d.ts +87 -20
- package/search/search-executor/search-enrichers.js +44 -5
- package/search/search-executor/search-generators.d.ts +4 -4
- package/search/search-executor/search-generators.js +12 -7
- package/search/search-executor/search-mappers.js +3 -2
- package/search/search-executor/search-transformer.d.ts +3 -3
- package/search/search-executor/search-transformer.js +2 -2
- package/slicing/static/fingerprint.js +1 -2
- package/slicing/static/slice-call.d.ts +2 -1
- package/slicing/static/slice-call.js +3 -3
- package/slicing/static/static-slicer.d.ts +6 -5
- package/slicing/static/static-slicer.js +13 -7
- package/util/collections/arrays.d.ts +2 -0
- package/util/collections/arrays.js +9 -0
- package/util/containers.d.ts +1 -0
- package/util/containers.js +1 -0
- package/util/json.js +1 -4
- package/util/mermaid/dfg.js +5 -4
- package/util/prefix.d.ts +1 -1
- package/util/range.d.ts +1 -0
- package/util/range.js +5 -1
- package/util/version.js +1 -1
|
@@ -20,11 +20,12 @@ const strings_1 = require("../util/text/strings");
|
|
|
20
20
|
const assert_1 = require("../util/assert");
|
|
21
21
|
const doc_print_1 = require("./doc-util/doc-print");
|
|
22
22
|
const doc_functions_1 = require("./doc-util/doc-functions");
|
|
23
|
+
const linter_format_1 = require("../linter/linter-format");
|
|
23
24
|
const SpecialTagColors = {
|
|
24
25
|
[linter_tags_1.LintingRuleTag.Bug]: 'red',
|
|
25
26
|
[linter_tags_1.LintingRuleTag.Security]: 'orange',
|
|
26
27
|
[linter_tags_1.LintingRuleTag.Smell]: 'yellow',
|
|
27
|
-
[linter_tags_1.LintingRuleTag.QuickFix]: 'lightgray'
|
|
28
|
+
[linter_tags_1.LintingRuleTag.QuickFix]: 'lightgray'
|
|
28
29
|
};
|
|
29
30
|
function makeTagBadge(name, info) {
|
|
30
31
|
const doc = (0, doc_types_1.getDocumentationForType)('LintingRuleTag::' + name, info, '', true).replaceAll('\n', ' ');
|
|
@@ -112,6 +113,7 @@ print(myVar)
|
|
|
112
113
|
df <- data.frame(id = 1:5, name = 6:10)
|
|
113
114
|
df[6, "value"]
|
|
114
115
|
`, tagTypes);
|
|
116
|
+
rule(shell, 'dead-code', 'DeadCodeConfig', 'DEAD_CODE', 'lint-dead-code', 'if(TRUE) 1 else 2', tagTypes);
|
|
115
117
|
function rule(shell, name, configType, ruleType, testfile, example, types) {
|
|
116
118
|
const rule = linter_rules_1.LintingRules[name];
|
|
117
119
|
const tags = rule.info.tags.toSorted((a, b) => {
|
|
@@ -130,6 +132,8 @@ df[6, "value"]
|
|
|
130
132
|
}
|
|
131
133
|
return a.localeCompare(b);
|
|
132
134
|
}).map(t => makeTagBadge(t, types)).join(' ');
|
|
135
|
+
const certaintyDoc = (0, doc_types_1.getDocumentationForType)(`LintingRuleCertainty::${rule.info.certainty}`, types, '', true).replaceAll('\n', ' ');
|
|
136
|
+
const certaintyText = `\`${(0, html_hover_over_1.textWithTooltip)(rule.info.certainty, certaintyDoc)}\``;
|
|
133
137
|
if (format === 'short') {
|
|
134
138
|
ruleExplanations.set(name, () => Promise.resolve(`
|
|
135
139
|
**[${rule.info.name}](${doc_files_1.FlowrWikiBaseRef}/lint-${name}):** ${rule.info.description} [see ${(0, doc_types_1.shortLinkFile)(ruleType, types)}]\\
|
|
@@ -144,6 +148,9 @@ ${(0, doc_auto_gen_1.autoGenHeader)({ filename: module.filename, purpose: 'linte
|
|
|
144
148
|
${(0, doc_structure_1.section)(rule.info.name + ` <sup>[<a href="${doc_files_1.FlowrWikiBaseRef}/Linter">overview</a>]</sup>`, 2, name)}
|
|
145
149
|
|
|
146
150
|
${tags}
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
This rule is a ${certaintyText} rule.
|
|
147
154
|
|
|
148
155
|
${rule.info.description}\\
|
|
149
156
|
_This linting rule is implemented in ${(0, doc_types_1.shortLinkFile)(ruleType, types)}._
|
|
@@ -171,9 +178,12 @@ ${buildSamplesFromLinterTestCases(shell, `${testfile}.test.ts`)}
|
|
|
171
178
|
}
|
|
172
179
|
return ruleExplanations;
|
|
173
180
|
}
|
|
174
|
-
function
|
|
181
|
+
function getAllLintingRulesWithTag(tag) {
|
|
175
182
|
return Object.entries(linter_rules_1.LintingRules).filter(([_, rule]) => rule.info.tags.includes(tag)).map(([name]) => name);
|
|
176
183
|
}
|
|
184
|
+
function getAllLintingRulesWitCertainty(certainty) {
|
|
185
|
+
return Object.entries(linter_rules_1.LintingRules).filter(([_, rule]) => rule.info.certainty === certainty).map(([name]) => name);
|
|
186
|
+
}
|
|
177
187
|
function linkToRule(name) {
|
|
178
188
|
return `[${name}](${doc_files_1.FlowrWikiBaseRef}/lint-${name})`;
|
|
179
189
|
}
|
|
@@ -214,14 +224,32 @@ ${await (async () => {
|
|
|
214
224
|
|
|
215
225
|
${(0, doc_structure_1.section)('Tags', 2, 'tags')}
|
|
216
226
|
|
|
217
|
-
We use tags to categorize linting rules. The following tags are available:
|
|
227
|
+
We use tags to categorize linting rules for users. The following tags are available:
|
|
218
228
|
|
|
219
229
|
| Tag/Badge   | Description |
|
|
220
230
|
| --- | :-- |
|
|
221
231
|
${Object.entries(linter_tags_1.LintingRuleTag).map(([name, tag]) => {
|
|
222
|
-
return `| <a id="${tag}"></a> ${makeTagBadge(tag, tagTypes.info)} | ${(0, doc_types_1.getDocumentationForType)('LintingRuleTag::' + name, tagTypes.info).replaceAll(/\n/g, ' ')} (rule${
|
|
232
|
+
return `| <a id="${tag}"></a> ${(makeTagBadge(tag, tagTypes.info))} | ${(0, doc_types_1.getDocumentationForType)('LintingRuleTag::' + name, tagTypes.info).replaceAll(/\n/g, ' ')} (rule${getAllLintingRulesWithTag(tag).length === 1 ? '' : 's'}: ${(0, strings_1.joinWithLast)(getAllLintingRulesWithTag(tag).map(l => linkToRule(l))) || '_none_'}) | `;
|
|
233
|
+
}).join('\n')}
|
|
234
|
+
|
|
235
|
+
${(0, doc_structure_1.section)('Certainty', 2, 'certainty')}
|
|
236
|
+
|
|
237
|
+
Both linting rules and their individual results are additionally categorized by how certain the linter is that the results it is returning are valid.
|
|
238
|
+
|
|
239
|
+
${(0, doc_structure_1.section)('Rule Certainty', 3, 'rule-certainty')}
|
|
240
|
+
|
|
241
|
+
| Rule Certainty | Description |
|
|
242
|
+
| -------------- | :---------- |
|
|
243
|
+
${Object.entries(linter_format_1.LintingRuleCertainty).map(([name, certainty]) => {
|
|
244
|
+
return `| <a id="${certainty}"></a> \`${certainty}\` | ${(0, doc_types_1.getDocumentationForType)('LintingRuleCertainty::' + name, tagTypes.info).replaceAll(/\n/g, ' ')} (rule${getAllLintingRulesWitCertainty(certainty).length === 1 ? '' : 's'}: ${(0, strings_1.joinWithLast)(getAllLintingRulesWitCertainty(certainty).map(l => linkToRule(l))) || '_none_'}) |`;
|
|
223
245
|
}).join('\n')}
|
|
224
246
|
|
|
247
|
+
${(0, doc_structure_1.section)('Result Certainty', 3, 'result-certainty')}
|
|
248
|
+
|
|
249
|
+
| Result Certainty | Description |
|
|
250
|
+
| ---------------- | :---------- |
|
|
251
|
+
${Object.entries(linter_format_1.LintingResultCertainty).map(([name, certainty]) => `| <a id="${certainty}"></a> \`${certainty}\` | ${(0, doc_types_1.getDocumentationForType)('LintingResultCertainty::' + name, tagTypes.info).replaceAll(/\n/g, ' ')} |`).join('\n')}
|
|
252
|
+
|
|
225
253
|
`.trim();
|
|
226
254
|
}
|
|
227
255
|
async function getRulesPages(shell, tagTypes, rVersion) {
|
|
@@ -4,16 +4,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const log_1 = require("../../test/functionality/_helper/log");
|
|
7
|
+
const log_2 = require("../util/log");
|
|
7
8
|
const doc_code_1 = require("./doc-util/doc-code");
|
|
8
9
|
const doc_files_1 = require("./doc-util/doc-files");
|
|
9
10
|
const doc_structure_1 = require("./doc-util/doc-structure");
|
|
10
11
|
const doc_types_1 = require("./doc-util/doc-types");
|
|
11
12
|
const path_1 = __importDefault(require("path"));
|
|
12
13
|
const doc_auto_gen_1 = require("./doc-util/doc-auto-gen");
|
|
14
|
+
const doc_cli_option_1 = require("./doc-util/doc-cli-option");
|
|
13
15
|
function getText() {
|
|
14
16
|
const { info } = (0, doc_types_1.getTypesFromFolder)({
|
|
15
17
|
rootFolder: path_1.default.resolve('./test'),
|
|
16
|
-
files: [path_1.default.resolve('./src/dataflow/graph/dataflowgraph-builder.ts')],
|
|
18
|
+
files: [path_1.default.resolve('./src/dataflow/graph/dataflowgraph-builder.ts'), path_1.default.resolve('./src/util/log.ts'), path_1.default.resolve('./src/slicing/static/static-slicer.ts')],
|
|
17
19
|
typeNameForMermaid: 'parameter',
|
|
18
20
|
inlineTypes: doc_types_1.mermaidHide
|
|
19
21
|
});
|
|
@@ -39,6 +41,7 @@ for the latest benchmark results, see the [benchmark results](${doc_files_1.Flow
|
|
|
39
41
|
- [License Checker](#license-checker)
|
|
40
42
|
- [🐛 Debugging](#debugging)
|
|
41
43
|
- [VS Code](#vs-code-1)
|
|
44
|
+
- [Logging](#logging)
|
|
42
45
|
|
|
43
46
|
<a id='testing-suites'></a>
|
|
44
47
|
## 🏨 Testing Suites
|
|
@@ -254,6 +257,15 @@ However, in case you think that the linter is wrong, please do not hesitate to o
|
|
|
254
257
|
### VS Code
|
|
255
258
|
When working with VS Code, you can attach a debugger to the REPL. This works automatically by running the \`Start Debugging\` command (\`F5\` by default).
|
|
256
259
|
You can also set the \`Auto Attach Filter\` setting to automatically attach the debugger, when running \`npm run flowr\`.
|
|
260
|
+
|
|
261
|
+
### Logging
|
|
262
|
+
|
|
263
|
+
*flowR* uses a wrapper around [tslog](https://www.npmjs.com/package/tslog) using a class named
|
|
264
|
+
${(0, doc_types_1.shortLink)(log_2.FlowrLogger.name, info)}. They obey to, for example, the ${(0, doc_cli_option_1.getCliLongOptionOf)('flowr', 'verbose')}
|
|
265
|
+
option. Throughout *flowR*, we use the \`log\` object (or subloggers of it) for logging.
|
|
266
|
+
To create your own logger, you can use ${(0, doc_types_1.shortLink)(log_2.FlowrLogger.name + '::' + (new log_2.FlowrLogger().getSubLogger.name), info, true, 'i')}.
|
|
267
|
+
For example, check out the ${(0, doc_types_1.shortLink)('slicerLogger', info)} for the static slicer.
|
|
268
|
+
|
|
257
269
|
`;
|
|
258
270
|
}
|
|
259
271
|
if (require.main === module) {
|
|
@@ -13,6 +13,10 @@ To get started developing on *flowR*, we recommend carefully reading the followi
|
|
|
13
13
|
- 💖 [Contributing guidelines](${doc_files_1.FlowrGithubBaseRef}/flowr/tree/main/.github/CONTRIBUTING.md).\
|
|
14
14
|
This page also includes information about how to set up **git-lfs** and several **git hooks**.
|
|
15
15
|
|
|
16
|
+
If you have any questions, please check out the [FAQ](${doc_files_1.FlowrWikiBaseRef}/FAQ) first, but if the question
|
|
17
|
+
is not answered there (or in the wiki in general), feel free to ask a question.
|
|
18
|
+
|
|
19
|
+
|
|
16
20
|
## ⌛ TL;DR
|
|
17
21
|
|
|
18
22
|
The most important steps to get the *flowR* development environment set up (after installing **R** and **Node.js**) can be seen below. For convenience, they can be executed all at once using the following command:
|
|
@@ -37,6 +37,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
37
37
|
const control_flow_query_executor_1 = require("../queries/catalog/control-flow-query/control-flow-query-executor");
|
|
38
38
|
const doc_cfg_1 = require("./doc-util/doc-cfg");
|
|
39
39
|
const df_shape_query_executor_1 = require("../queries/catalog/df-shape-query/df-shape-query-executor");
|
|
40
|
+
const _00_slice_1 = require("../core/steps/all/static-slicing/00-slice");
|
|
40
41
|
(0, doc_query_1.registerQueryDocumentation)('call-context', {
|
|
41
42
|
name: 'Call-Context Query',
|
|
42
43
|
type: 'active',
|
|
@@ -407,15 +408,15 @@ Now, the results no longer contain calls to \`plot\` that are not defined locall
|
|
|
407
408
|
(0, doc_query_1.registerQueryDocumentation)('static-slice', {
|
|
408
409
|
name: 'Static Slice Query',
|
|
409
410
|
type: 'active',
|
|
410
|
-
shortDescription: 'Slice the dataflow graph reducing the code to just the parts relevant for the given criteria.',
|
|
411
|
+
shortDescription: 'Slice the dataflow graph reducing the code to just the parts relevant for the given criteria (backward and forward).',
|
|
411
412
|
functionName: static_slice_query_executor_1.executeStaticSliceQuery.name,
|
|
412
413
|
functionFile: '../queries/catalog/static-slice-query/static-slice-query-executor.ts',
|
|
413
414
|
buildExplanation: async (shell) => {
|
|
414
415
|
const exampleCode = 'x <- 1\ny <- 2\nx';
|
|
415
416
|
return `
|
|
416
417
|
To slice, _flowR_ needs one thing from you: a variable or a list of variables (function calls are supported to, referring to the anonymous
|
|
417
|
-
return of the call) that you want to slice the dataflow graph for.
|
|
418
|
-
Given this, the slice is essentially the subpart of the program that may influence the value of the variables you are interested in.
|
|
418
|
+
return of the call) that you want to slice the dataflow graph for (additionally, you have to tell flowR if you want to have a forward slice).
|
|
419
|
+
Given this, the backward slice is essentially the subpart of the program that may influence the value of the variables you are interested in.
|
|
419
420
|
To specify a variable of interest, you have to present flowR with a [slicing criterion](${doc_files_1.FlowrWikiBaseRef}/Terminology#slicing-criterion) (or, respectively, an array of them).
|
|
420
421
|
|
|
421
422
|
To exemplify the capabilities, consider the following code:
|
|
@@ -436,6 +437,14 @@ ${(0, doc_structure_1.details)('No Reconstruction Example', await (0, doc_query_
|
|
|
436
437
|
noReconstruction: true
|
|
437
438
|
}], { showCode: false }))}
|
|
438
439
|
|
|
440
|
+
Likewise, if you want the forward slice for the first use of \`x\`, you can do it like this:
|
|
441
|
+
|
|
442
|
+
${await (0, doc_query_1.showQuery)(shell, exampleCode, [{
|
|
443
|
+
type: 'static-slice',
|
|
444
|
+
criteria: ['1@x'],
|
|
445
|
+
direction: _00_slice_1.SliceDirection.Forward
|
|
446
|
+
}], { showCode: false })}
|
|
447
|
+
|
|
439
448
|
You can disable [magic comments](${doc_files_1.FlowrWikiBaseRef}/Interface#slice-magic-comments) using the \`noMagicComments\` flag.
|
|
440
449
|
This query replaces the old [\`request-slice\`](${doc_files_1.FlowrWikiBaseRef}/Interface#message-request-slice) message.
|
|
441
450
|
`;
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.executeLintingRule = executeLintingRule;
|
|
4
4
|
const linter_rules_1 = require("./linter-rules");
|
|
5
5
|
const flowr_search_executor_1 = require("../search/flowr-search-executor");
|
|
6
|
-
const flowr_search_1 = require("../search/flowr-search");
|
|
7
6
|
const objects_1 = require("../util/objects");
|
|
8
7
|
function executeLintingRule(ruleName, input, lintingRuleConfig) {
|
|
9
8
|
const rule = linter_rules_1.LintingRules[ruleName];
|
|
@@ -13,7 +12,7 @@ function executeLintingRule(ruleName, input, lintingRuleConfig) {
|
|
|
13
12
|
const searchResult = (0, flowr_search_executor_1.runSearch)(ruleSearch, input);
|
|
14
13
|
const searchTime = Date.now() - searchStart;
|
|
15
14
|
const processStart = Date.now();
|
|
16
|
-
const result = rule.processSearchResult(
|
|
15
|
+
const result = rule.processSearchResult(searchResult, fullConfig, input);
|
|
17
16
|
const processTime = Date.now() - processStart;
|
|
18
17
|
return {
|
|
19
18
|
...result,
|
|
@@ -22,6 +22,10 @@ export interface LinterRuleInformation<Config extends MergeableRecord = never> {
|
|
|
22
22
|
* A short list of tags that describe and categorize the linting rule.
|
|
23
23
|
*/
|
|
24
24
|
readonly tags: readonly LintingRuleTag[];
|
|
25
|
+
/**
|
|
26
|
+
* The linting rule's certainty in terms of the rule's calculations' precision and recall.
|
|
27
|
+
*/
|
|
28
|
+
readonly certainty: LintingRuleCertainty;
|
|
25
29
|
/**
|
|
26
30
|
* A short description of the linting rule.
|
|
27
31
|
* This is used to display the rule in the UI and to provide a brief overview of what the rule does.
|
|
@@ -91,7 +95,7 @@ export type LintQuickFix = LintQuickFixReplacement | LintQuickFixRemove;
|
|
|
91
95
|
* A linting result for a single linting rule match.
|
|
92
96
|
*/
|
|
93
97
|
export interface LintingResult {
|
|
94
|
-
readonly certainty:
|
|
98
|
+
readonly certainty: LintingResultCertainty;
|
|
95
99
|
/**
|
|
96
100
|
* If available, what to do to fix the linting result.
|
|
97
101
|
*/
|
|
@@ -108,15 +112,33 @@ export interface LintingResults<Name extends LintingRuleNames> {
|
|
|
108
112
|
readonly processTimeMs: number;
|
|
109
113
|
};
|
|
110
114
|
}
|
|
111
|
-
export declare enum
|
|
115
|
+
export declare enum LintingResultCertainty {
|
|
112
116
|
/**
|
|
113
117
|
* The linting rule cannot say for sure whether the result is correct or not.
|
|
118
|
+
* This linting certainty should be used for linting results whose calculations are based on estimations involving unknown side-effects, reflection, etc.
|
|
114
119
|
*/
|
|
115
|
-
|
|
120
|
+
Uncertain = "uncertain",
|
|
116
121
|
/**
|
|
117
122
|
* The linting rule is certain that the reported lint is real.
|
|
123
|
+
* This linting certainty should be used for linting results whose calculations do not involve estimates or other unknown factors.
|
|
124
|
+
*/
|
|
125
|
+
Certain = "certain"
|
|
126
|
+
}
|
|
127
|
+
export declare enum LintingRuleCertainty {
|
|
128
|
+
/**
|
|
129
|
+
* Linting rules that are expected to have both high precision and high recall.
|
|
130
|
+
*/
|
|
131
|
+
Exact = "exact",
|
|
132
|
+
/**
|
|
133
|
+
* Linting rules that are expected to have high precision, but not necessarily high recall.
|
|
134
|
+
* Rules with this certainty generally ensure that the results they return are correct, but may not return all results.
|
|
135
|
+
*/
|
|
136
|
+
BestEffort = "best-effort",
|
|
137
|
+
/**
|
|
138
|
+
* Linting rules that are expected to have high recall, but not necessarily high precision.
|
|
139
|
+
* Rules with this certainty generally return all relevant results, but may also include some incorrect matches.
|
|
118
140
|
*/
|
|
119
|
-
|
|
141
|
+
OverApproximative = "over-approximative"
|
|
120
142
|
}
|
|
121
143
|
export declare enum LintingPrettyPrintContext {
|
|
122
144
|
Query = "query",
|
package/linter/linter-format.js
CHANGED
|
@@ -1,17 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LintingPrettyPrintContext = exports.
|
|
4
|
-
var
|
|
5
|
-
(function (
|
|
3
|
+
exports.LintingPrettyPrintContext = exports.LintingRuleCertainty = exports.LintingResultCertainty = void 0;
|
|
4
|
+
var LintingResultCertainty;
|
|
5
|
+
(function (LintingResultCertainty) {
|
|
6
6
|
/**
|
|
7
7
|
* The linting rule cannot say for sure whether the result is correct or not.
|
|
8
|
+
* This linting certainty should be used for linting results whose calculations are based on estimations involving unknown side-effects, reflection, etc.
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
+
LintingResultCertainty["Uncertain"] = "uncertain";
|
|
10
11
|
/**
|
|
11
12
|
* The linting rule is certain that the reported lint is real.
|
|
13
|
+
* This linting certainty should be used for linting results whose calculations do not involve estimates or other unknown factors.
|
|
12
14
|
*/
|
|
13
|
-
|
|
14
|
-
})(
|
|
15
|
+
LintingResultCertainty["Certain"] = "certain";
|
|
16
|
+
})(LintingResultCertainty || (exports.LintingResultCertainty = LintingResultCertainty = {}));
|
|
17
|
+
var LintingRuleCertainty;
|
|
18
|
+
(function (LintingRuleCertainty) {
|
|
19
|
+
/**
|
|
20
|
+
* Linting rules that are expected to have both high precision and high recall.
|
|
21
|
+
*/
|
|
22
|
+
LintingRuleCertainty["Exact"] = "exact";
|
|
23
|
+
/**
|
|
24
|
+
* Linting rules that are expected to have high precision, but not necessarily high recall.
|
|
25
|
+
* Rules with this certainty generally ensure that the results they return are correct, but may not return all results.
|
|
26
|
+
*/
|
|
27
|
+
LintingRuleCertainty["BestEffort"] = "best-effort";
|
|
28
|
+
/**
|
|
29
|
+
* Linting rules that are expected to have high recall, but not necessarily high precision.
|
|
30
|
+
* Rules with this certainty generally return all relevant results, but may also include some incorrect matches.
|
|
31
|
+
*/
|
|
32
|
+
LintingRuleCertainty["OverApproximative"] = "over-approximative";
|
|
33
|
+
})(LintingRuleCertainty || (exports.LintingRuleCertainty = LintingRuleCertainty = {}));
|
|
15
34
|
var LintingPrettyPrintContext;
|
|
16
35
|
(function (LintingPrettyPrintContext) {
|
|
17
36
|
LintingPrettyPrintContext["Query"] = "query";
|
package/linter/linter-rules.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare const LintingRules: {
|
|
|
8
8
|
readonly createSearch: (config: import("./rules/deprecated-functions").DeprecatedFunctionsConfig) => import("../search/flowr-search-builder").FlowrSearchBuilder<"all", ["with", "filter"], import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>;
|
|
9
9
|
readonly processSearchResult: (elements: import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>) => {
|
|
10
10
|
results: {
|
|
11
|
-
certainty: import("./linter-format").
|
|
11
|
+
certainty: import("./linter-format").LintingResultCertainty.Certain;
|
|
12
12
|
function: import("../dataflow/environments/identifier").Identifier;
|
|
13
13
|
range: import("../util/range").SourceRange;
|
|
14
14
|
}[];
|
|
@@ -21,6 +21,7 @@ export declare const LintingRules: {
|
|
|
21
21
|
readonly info: {
|
|
22
22
|
readonly name: "Deprecated Functions";
|
|
23
23
|
readonly tags: readonly [import("./linter-tags").LintingRuleTag.Deprecated, import("./linter-tags").LintingRuleTag.Smell, import("./linter-tags").LintingRuleTag.Usability, import("./linter-tags").LintingRuleTag.Reproducibility];
|
|
24
|
+
readonly certainty: import("./linter-format").LintingRuleCertainty.BestEffort;
|
|
24
25
|
readonly description: "Marks deprecated functions that should not be used anymore.";
|
|
25
26
|
readonly defaultConfig: {
|
|
26
27
|
readonly deprecatedFunctions: readonly ["all_equal", "arrange_all", "distinct_all", "filter_all", "group_by_all", "summarise_all", "mutate_all", "select_all", "vars", "all_vars", "id", "failwith", "select_vars", "rename_vars", "select_var", "current_vars", "bench_tbls", "compare_tbls", "compare_tbls2", "eval_tbls", "eval_tbls2", "location", "changes", "combine", "do", "funs", "add_count_", "add_tally_", "arrange_", "count_", "distinct_", "do_", "filter_", "funs_", "group_by_", "group_indices_", "mutate_", "tally_", "transmute_", "rename_", "rename_vars_", "select_", "select_vars_", "slice_", "summarise_", "summarize_", "summarise_each", "src_local", "tbl_df", "add_rownames", "group_nest", "group_split", "with_groups", "nest_by", "progress_estimated", "recode", "sample_n", "top_n", "transmute", "fct_explicit_na", "aes_", "aes_auto", "annotation_logticks", "is.Coord", "coord_flip", "coord_map", "is.facet", "fortify", "is.ggproto", "guide_train", "is.ggplot", "qplot", "is.theme", "gg_dep", "liply", "isplit2", "list_along", "cross", "invoke", "at_depth", "prepend", "rerun", "splice", "`%@%`", "rbernoulli", "rdunif", "when", "update_list", "map_raw", "accumulate", "reduce_right", "flatten", "map_dfr", "as_vector", "transpose", "melt_delim", "melt_fwf", "melt_table", "read_table2", "str_interp", "as_tibble", "data_frame", "tibble_", "data_frame_", "lst_", "as_data_frame", "as.tibble", "frame_data", "trunc_mat", "is.tibble", "tidy_names", "set_tidy_names", "repair_names", "extract_numeric", "complete_", "drop_na_", "expand_", "crossing_", "nesting_", "extract_", "fill_", "gather_", "nest_", "separate_rows_", "separate_", "spread_", "unite_", "unnest_", "extract", "gather", "nest_legacy", "separate_rows", "separate", "spread"];
|
|
@@ -28,8 +29,8 @@ export declare const LintingRules: {
|
|
|
28
29
|
};
|
|
29
30
|
};
|
|
30
31
|
readonly 'file-path-validity': {
|
|
31
|
-
readonly createSearch: (config: import("./rules/file-path-validity").FilePathValidityConfig) => import("../search/flowr-search-builder").FlowrSearchBuilder<"from-query", [], import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").
|
|
32
|
-
readonly processSearchResult: (elements: import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").
|
|
32
|
+
readonly createSearch: (config: import("./rules/file-path-validity").FilePathValidityConfig) => import("../search/flowr-search-builder").FlowrSearchBuilder<"from-query", ["with"], import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>;
|
|
33
|
+
readonly processSearchResult: (elements: import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, config: import("./rules/file-path-validity").FilePathValidityConfig, data: {
|
|
33
34
|
normalize: import("../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
|
|
34
35
|
dataflow: import("../dataflow/info").DataflowInformation;
|
|
35
36
|
config: import("../config").FlowrConfigOptions;
|
|
@@ -40,6 +41,7 @@ export declare const LintingRules: {
|
|
|
40
41
|
readonly info: {
|
|
41
42
|
readonly name: "File Path Validity";
|
|
42
43
|
readonly description: "Checks whether file paths used in read and write operations are valid and point to existing files.";
|
|
44
|
+
readonly certainty: import("./linter-format").LintingRuleCertainty.BestEffort;
|
|
43
45
|
readonly tags: readonly [import("./linter-tags").LintingRuleTag.Robustness, import("./linter-tags").LintingRuleTag.Reproducibility, import("./linter-tags").LintingRuleTag.Bug];
|
|
44
46
|
readonly defaultConfig: {
|
|
45
47
|
readonly additionalReadFunctions: readonly [];
|
|
@@ -53,14 +55,14 @@ export declare const LintingRules: {
|
|
|
53
55
|
};
|
|
54
56
|
};
|
|
55
57
|
readonly 'seeded-randomness': {
|
|
56
|
-
readonly createSearch: (config: import("./rules/seeded-randomness").SeededRandomnessConfig) => import("../search/flowr-search-builder").FlowrSearchBuilder<"all", ["with", "filter", "with"], import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/
|
|
58
|
+
readonly createSearch: (config: import("./rules/seeded-randomness").SeededRandomnessConfig) => import("../search/flowr-search-builder").FlowrSearchBuilder<"all", ["with", "filter", "with"], import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>;
|
|
57
59
|
readonly processSearchResult: (elements: import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, config: import("./rules/seeded-randomness").SeededRandomnessConfig, { dataflow }: {
|
|
58
60
|
normalize: import("../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
|
|
59
61
|
dataflow: import("../dataflow/info").DataflowInformation;
|
|
60
62
|
config: import("../config").FlowrConfigOptions;
|
|
61
63
|
}) => {
|
|
62
64
|
results: {
|
|
63
|
-
certainty: import("./linter-format").
|
|
65
|
+
certainty: import("./linter-format").LintingResultCertainty.Certain;
|
|
64
66
|
function: import("../dataflow/environments/identifier").Identifier;
|
|
65
67
|
range: import("../util/range").SourceRange;
|
|
66
68
|
}[];
|
|
@@ -78,6 +80,7 @@ export declare const LintingRules: {
|
|
|
78
80
|
readonly randomnessConsumers: readonly ["jitter", "sample", "sample.int", "arima.sim", "kmeans", "princomp", "rcauchy", "rchisq", "rexp", "rgamma", "rgeom", "rlnorm", "rlogis", "rmultinom", "rnbinom", "rnorm", "rpois", "runif", "pointLabel", "some", "rbernoulli", "rdunif", "generateSeedVectors"];
|
|
79
81
|
};
|
|
80
82
|
readonly tags: readonly [import("./linter-tags").LintingRuleTag.Robustness, import("./linter-tags").LintingRuleTag.Reproducibility];
|
|
83
|
+
readonly certainty: import("./linter-format").LintingRuleCertainty.BestEffort;
|
|
81
84
|
readonly name: "Seeded Randomness";
|
|
82
85
|
readonly description: "Checks whether randomness-based function calls are preceded by a random seed generation function. For consistent reproducibility, functions that use randomness should only be called after a constant random seed is set using a function like `set.seed`.";
|
|
83
86
|
};
|
|
@@ -88,11 +91,7 @@ export declare const LintingRules: {
|
|
|
88
91
|
};
|
|
89
92
|
readonly 'absolute-file-paths': {
|
|
90
93
|
readonly createSearch: (config: import("./rules/absolute-path").AbsoluteFilePathConfig) => import("../search/flowr-search-builder").FlowrSearchBuilder<"from-query", ["unique"], import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>;
|
|
91
|
-
readonly processSearchResult: (elements: import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, {
|
|
92
|
-
readonly query?: "config" | "origin" | "dataflow" | "search" | "call-context" | "control-flow" | "dataflow-lens" | "df-shape" | "normalized-ast" | "id-map" | "dataflow-cluster" | "static-slice" | "lineage" | "dependencies" | "location-map" | "happens-before" | "resolve-value" | "project" | "linter" | undefined;
|
|
93
|
-
readonly queryResult?: import("../queries/base-query-format").BaseQueryResult | undefined;
|
|
94
|
-
readonly node: import("../r-bridge/lang-4.x/ast/model/nodes/r-expression-list").RExpressionList<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation> | import("../r-bridge/lang-4.x/ast/model/nodes/r-function-definition").RFunctionDefinition<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation> | import("../r-bridge/lang-4.x/ast/model/nodes/r-function-call").RNamedFunctionCall<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation> | import("../r-bridge/lang-4.x/ast/model/nodes/r-function-call").RUnnamedFunctionCall<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation> | import("../r-bridge/lang-4.x/ast/model/nodes/r-parameter").RParameter<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation> | import("../r-bridge/lang-4.x/ast/model/nodes/r-argument").RArgument<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation> | import("../r-bridge/lang-4.x/ast/model/nodes/r-comment").RComment<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation> | import("../r-bridge/lang-4.x/ast/model/nodes/r-line-directive").RLineDirective<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation> | import("../r-bridge/lang-4.x/ast/model/nodes/r-for-loop").RForLoop<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation> | import("../r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop").RRepeatLoop<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation> | import("../r-bridge/lang-4.x/ast/model/nodes/r-while-loop").RWhileLoop<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation> | import("../r-bridge/lang-4.x/ast/model/nodes/r-if-then-else").RIfThenElse<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation> | import("../r-bridge/lang-4.x/ast/model/nodes/r-access").RNamedAccess<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation> | import("../r-bridge/lang-4.x/ast/model/nodes/r-access").RIndexAccess<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation> | import("../r-bridge/lang-4.x/ast/model/nodes/r-unary-op").RUnaryOp<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation> | import("../r-bridge/lang-4.x/ast/model/nodes/r-binary-op").RBinaryOp<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation> | import("../r-bridge/lang-4.x/ast/model/nodes/r-symbol").RSymbol<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, string> | import("../r-bridge/lang-4.x/ast/model/nodes/r-number").RNumber<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation> | import("../r-bridge/lang-4.x/ast/model/nodes/r-string").RString<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation> | import("../r-bridge/lang-4.x/ast/model/nodes/r-logical").RLogical<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation> | import("../r-bridge/lang-4.x/ast/model/nodes/r-break").RBreak<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation> | import("../r-bridge/lang-4.x/ast/model/nodes/r-next").RNext<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation> | import("../r-bridge/lang-4.x/ast/model/nodes/r-pipe").RPipe<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>;
|
|
95
|
-
}[]>, config: import("./rules/absolute-path").AbsoluteFilePathConfig, data: {
|
|
94
|
+
readonly processSearchResult: (elements: import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, config: import("./rules/absolute-path").AbsoluteFilePathConfig, data: {
|
|
96
95
|
normalize: import("../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
|
|
97
96
|
dataflow: import("../dataflow/info").DataflowInformation;
|
|
98
97
|
config: import("../config").FlowrConfigOptions;
|
|
@@ -108,6 +107,7 @@ export declare const LintingRules: {
|
|
|
108
107
|
readonly name: "Absolute Paths";
|
|
109
108
|
readonly description: "Checks whether file paths are absolute.";
|
|
110
109
|
readonly tags: readonly [import("./linter-tags").LintingRuleTag.Robustness, import("./linter-tags").LintingRuleTag.Reproducibility, import("./linter-tags").LintingRuleTag.Smell, import("./linter-tags").LintingRuleTag.QuickFix];
|
|
110
|
+
readonly certainty: import("./linter-format").LintingRuleCertainty.BestEffort;
|
|
111
111
|
readonly defaultConfig: {
|
|
112
112
|
readonly include: {
|
|
113
113
|
readonly constructed: true;
|
|
@@ -137,6 +137,7 @@ export declare const LintingRules: {
|
|
|
137
137
|
readonly name: "Unused Definitions";
|
|
138
138
|
readonly description: "Checks for unused definitions.";
|
|
139
139
|
readonly tags: readonly [import("./linter-tags").LintingRuleTag.Readability, import("./linter-tags").LintingRuleTag.Smell, import("./linter-tags").LintingRuleTag.QuickFix];
|
|
140
|
+
readonly certainty: import("./linter-format").LintingRuleCertainty.BestEffort;
|
|
140
141
|
readonly defaultConfig: {
|
|
141
142
|
readonly includeFunctionDefinitions: true;
|
|
142
143
|
};
|
|
@@ -151,7 +152,7 @@ export declare const LintingRules: {
|
|
|
151
152
|
}) => {
|
|
152
153
|
results: {
|
|
153
154
|
quickFix: import("./linter-format").LintQuickFixReplacement[] | undefined;
|
|
154
|
-
certainty: import("./linter-format").
|
|
155
|
+
certainty: import("./linter-format").LintingResultCertainty;
|
|
155
156
|
detectedCasing: import("./rules/naming-convention").CasingConvention;
|
|
156
157
|
name: string;
|
|
157
158
|
range: import("../util/range").SourceRange;
|
|
@@ -167,6 +168,7 @@ export declare const LintingRules: {
|
|
|
167
168
|
};
|
|
168
169
|
readonly info: {
|
|
169
170
|
readonly name: "Naming Convention";
|
|
171
|
+
readonly certainty: import("./linter-format").LintingRuleCertainty.OverApproximative;
|
|
170
172
|
readonly description: "Checks wether the symbols conform to a certain naming convention";
|
|
171
173
|
readonly tags: readonly [import("./linter-tags").LintingRuleTag.Style, import("./linter-tags").LintingRuleTag.QuickFix];
|
|
172
174
|
readonly defaultConfig: {
|
|
@@ -175,7 +177,7 @@ export declare const LintingRules: {
|
|
|
175
177
|
};
|
|
176
178
|
};
|
|
177
179
|
readonly 'dataframe-access-validation': {
|
|
178
|
-
readonly createSearch: () => import("../search/flowr-search-builder").FlowrSearchBuilder<"all", ["with"], import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/
|
|
180
|
+
readonly createSearch: () => import("../search/flowr-search-builder").FlowrSearchBuilder<"all", ["with"], import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>;
|
|
179
181
|
readonly processSearchResult: (elements: import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, config: import("./rules/dataframe-access-validation").DataFrameAccessValidationConfig, data: {
|
|
180
182
|
normalize: import("../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
|
|
181
183
|
dataflow: import("../dataflow/info").DataflowInformation;
|
|
@@ -191,12 +193,38 @@ export declare const LintingRules: {
|
|
|
191
193
|
readonly info: {
|
|
192
194
|
readonly name: "Dataframe Access Validation";
|
|
193
195
|
readonly tags: readonly [import("./linter-tags").LintingRuleTag.Bug, import("./linter-tags").LintingRuleTag.Usability, import("./linter-tags").LintingRuleTag.Reproducibility];
|
|
196
|
+
readonly certainty: import("./linter-format").LintingRuleCertainty.BestEffort;
|
|
194
197
|
readonly description: "Validates the existance of accessed columns and rows of dataframes.";
|
|
195
198
|
readonly defaultConfig: {
|
|
196
199
|
readonly readLoadedData: false;
|
|
197
200
|
};
|
|
198
201
|
};
|
|
199
202
|
};
|
|
203
|
+
readonly 'dead-code': {
|
|
204
|
+
readonly createSearch: (config: import("./rules/dead-code").DeadCodeConfig) => import("../search/flowr-search-builder").FlowrSearchBuilder<"all", ["with"], import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>;
|
|
205
|
+
readonly processSearchResult: (elements: import("../search/flowr-search").FlowrSearchElements<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../search/flowr-search").FlowrSearchElement<import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, _config: import("./rules/dead-code").DeadCodeConfig, _data: {
|
|
206
|
+
normalize: import("../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
|
|
207
|
+
dataflow: import("../dataflow/info").DataflowInformation;
|
|
208
|
+
config: import("../config").FlowrConfigOptions;
|
|
209
|
+
}) => {
|
|
210
|
+
results: {
|
|
211
|
+
certainty: import("./linter-format").LintingResultCertainty.Certain;
|
|
212
|
+
range: import("../util/range").SourceRange;
|
|
213
|
+
}[];
|
|
214
|
+
'.meta': import("./rules/dead-code").DeadCodeMetadata;
|
|
215
|
+
};
|
|
216
|
+
readonly prettyPrint: {
|
|
217
|
+
readonly query: (result: import("./rules/dead-code").DeadCodeResult) => string;
|
|
218
|
+
readonly full: (result: import("./rules/dead-code").DeadCodeResult) => string;
|
|
219
|
+
};
|
|
220
|
+
readonly info: {
|
|
221
|
+
readonly name: "Dead Code";
|
|
222
|
+
readonly tags: readonly [import("./linter-tags").LintingRuleTag.Smell, import("./linter-tags").LintingRuleTag.Usability, import("./linter-tags").LintingRuleTag.Reproducibility];
|
|
223
|
+
readonly certainty: import("./linter-format").LintingRuleCertainty.BestEffort;
|
|
224
|
+
readonly description: "Marks areas of code that are never reached during execution.";
|
|
225
|
+
readonly defaultConfig: {};
|
|
226
|
+
};
|
|
227
|
+
};
|
|
200
228
|
};
|
|
201
229
|
export type LintingRuleNames = keyof typeof LintingRules;
|
|
202
230
|
export type LintingRuleMetadata<Name extends LintingRuleNames> = typeof LintingRules[Name] extends LintingRule<infer _Result, infer Metadata, infer _Config, infer _Info, infer _Elements> ? Metadata : never;
|
package/linter/linter-rules.js
CHANGED
|
@@ -5,6 +5,7 @@ const deprecated_functions_1 = require("./rules/deprecated-functions");
|
|
|
5
5
|
const file_path_validity_1 = require("./rules/file-path-validity");
|
|
6
6
|
const absolute_path_1 = require("./rules/absolute-path");
|
|
7
7
|
const unused_definition_1 = require("./rules/unused-definition");
|
|
8
|
+
const dead_code_1 = require("./rules/dead-code");
|
|
8
9
|
const seeded_randomness_1 = require("./rules/seeded-randomness");
|
|
9
10
|
const naming_convention_1 = require("./rules/naming-convention");
|
|
10
11
|
const dataframe_access_validation_1 = require("./rules/dataframe-access-validation");
|
|
@@ -19,6 +20,7 @@ exports.LintingRules = {
|
|
|
19
20
|
'absolute-file-paths': absolute_path_1.ABSOLUTE_PATH,
|
|
20
21
|
'unused-definitions': unused_definition_1.UNUSED_DEFINITION,
|
|
21
22
|
'naming-convention': naming_convention_1.NAMING_CONVENTION,
|
|
22
|
-
'dataframe-access-validation': dataframe_access_validation_1.DATA_FRAME_ACCESS_VALIDATION
|
|
23
|
+
'dataframe-access-validation': dataframe_access_validation_1.DATA_FRAME_ACCESS_VALIDATION,
|
|
24
|
+
'dead-code': dead_code_1.DEAD_CODE,
|
|
23
25
|
};
|
|
24
26
|
//# sourceMappingURL=linter-rules.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { LintingResult } from '../linter-format';
|
|
2
|
+
import { LintingRuleCertainty } from '../linter-format';
|
|
2
3
|
import type { MergeableRecord } from '../../util/objects';
|
|
3
4
|
import type { SourceRange } from '../../util/range';
|
|
4
5
|
import { LintingRuleTag } from '../linter-tags';
|
|
5
6
|
import type { FunctionInfo } from '../../queries/catalog/dependencies-query/function-info/function-info';
|
|
6
|
-
import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
7
7
|
import type { FlowrConfigOptions } from '../../config';
|
|
8
8
|
export interface AbsoluteFilePathResult extends LintingResult {
|
|
9
9
|
filePath: string;
|
|
@@ -36,12 +36,8 @@ export interface AbsoluteFilePathMetadata extends MergeableRecord {
|
|
|
36
36
|
totalUnknown: number;
|
|
37
37
|
}
|
|
38
38
|
export declare const ABSOLUTE_PATH: {
|
|
39
|
-
readonly createSearch: (config: AbsoluteFilePathConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"from-query", ["unique"], ParentInformation, import("../../search/flowr-search").FlowrSearchElements<ParentInformation, import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>>;
|
|
40
|
-
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<ParentInformation, {
|
|
41
|
-
readonly query?: "config" | "origin" | "dataflow" | "search" | "call-context" | "control-flow" | "dataflow-lens" | "df-shape" | "normalized-ast" | "id-map" | "dataflow-cluster" | "static-slice" | "lineage" | "dependencies" | "location-map" | "happens-before" | "resolve-value" | "project" | "linter" | undefined;
|
|
42
|
-
readonly queryResult?: import("../../queries/base-query-format").BaseQueryResult | undefined;
|
|
43
|
-
readonly node: import("../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list").RExpressionList<ParentInformation> | import("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition").RFunctionDefinition<ParentInformation> | import("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call").RNamedFunctionCall<ParentInformation> | import("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call").RUnnamedFunctionCall<ParentInformation> | import("../../r-bridge/lang-4.x/ast/model/nodes/r-parameter").RParameter<ParentInformation> | import("../../r-bridge/lang-4.x/ast/model/nodes/r-argument").RArgument<ParentInformation> | import("../../r-bridge/lang-4.x/ast/model/nodes/r-comment").RComment<ParentInformation> | import("../../r-bridge/lang-4.x/ast/model/nodes/r-line-directive").RLineDirective<ParentInformation> | import("../../r-bridge/lang-4.x/ast/model/nodes/r-for-loop").RForLoop<ParentInformation> | import("../../r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop").RRepeatLoop<ParentInformation> | import("../../r-bridge/lang-4.x/ast/model/nodes/r-while-loop").RWhileLoop<ParentInformation> | import("../../r-bridge/lang-4.x/ast/model/nodes/r-if-then-else").RIfThenElse<ParentInformation> | import("../../r-bridge/lang-4.x/ast/model/nodes/r-access").RNamedAccess<ParentInformation> | import("../../r-bridge/lang-4.x/ast/model/nodes/r-access").RIndexAccess<ParentInformation> | import("../../r-bridge/lang-4.x/ast/model/nodes/r-unary-op").RUnaryOp<ParentInformation> | import("../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op").RBinaryOp<ParentInformation> | import("../../r-bridge/lang-4.x/ast/model/nodes/r-symbol").RSymbol<ParentInformation, string> | import("../../r-bridge/lang-4.x/ast/model/nodes/r-number").RNumber<ParentInformation> | import("../../r-bridge/lang-4.x/ast/model/nodes/r-string").RString<ParentInformation> | import("../../r-bridge/lang-4.x/ast/model/nodes/r-logical").RLogical<ParentInformation> | import("../../r-bridge/lang-4.x/ast/model/nodes/r-break").RBreak<ParentInformation> | import("../../r-bridge/lang-4.x/ast/model/nodes/r-next").RNext<ParentInformation> | import("../../r-bridge/lang-4.x/ast/model/nodes/r-pipe").RPipe<ParentInformation>;
|
|
44
|
-
}[]>, config: AbsoluteFilePathConfig, data: {
|
|
39
|
+
readonly createSearch: (config: AbsoluteFilePathConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"from-query", ["unique"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>;
|
|
40
|
+
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, config: AbsoluteFilePathConfig, data: {
|
|
45
41
|
normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
|
|
46
42
|
dataflow: import("../../dataflow/info").DataflowInformation;
|
|
47
43
|
config: FlowrConfigOptions;
|
|
@@ -57,6 +53,7 @@ export declare const ABSOLUTE_PATH: {
|
|
|
57
53
|
readonly name: "Absolute Paths";
|
|
58
54
|
readonly description: "Checks whether file paths are absolute.";
|
|
59
55
|
readonly tags: readonly [LintingRuleTag.Robustness, LintingRuleTag.Reproducibility, LintingRuleTag.Smell, LintingRuleTag.QuickFix];
|
|
56
|
+
readonly certainty: LintingRuleCertainty.BestEffort;
|
|
60
57
|
readonly defaultConfig: {
|
|
61
58
|
readonly include: {
|
|
62
59
|
readonly constructed: true;
|
|
@@ -87,7 +87,7 @@ exports.ABSOLUTE_PATH = {
|
|
|
87
87
|
}
|
|
88
88
|
if (config.include.constructed) {
|
|
89
89
|
q = q.merge(flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.FunctionCall).with(search_enrichers_1.Enrichment.CallTargets));
|
|
90
|
-
/* in the future we want to directly check whether this is one of the supported functions */
|
|
90
|
+
/* in the future, we want to directly check whether this is one of the supported functions */
|
|
91
91
|
}
|
|
92
92
|
return q.unique();
|
|
93
93
|
},
|
|
@@ -96,6 +96,7 @@ exports.ABSOLUTE_PATH = {
|
|
|
96
96
|
totalConsidered: 0,
|
|
97
97
|
totalUnknown: 0
|
|
98
98
|
};
|
|
99
|
+
const queryResults = elements.enrichmentContent(search_enrichers_1.Enrichment.QueryData)?.queries;
|
|
99
100
|
const regex = config.absolutePathRegex ? new RegExp(config.absolutePathRegex) : undefined;
|
|
100
101
|
return {
|
|
101
102
|
results: elements.getElements().flatMap(element => {
|
|
@@ -105,7 +106,7 @@ exports.ABSOLUTE_PATH = {
|
|
|
105
106
|
if ((0, r_string_1.isRString)(node)) {
|
|
106
107
|
if (node.content.str.length >= 3 && (0, strings_1.isAbsolutePath)(node.content.str, regex)) {
|
|
107
108
|
return [{
|
|
108
|
-
certainty: linter_format_1.
|
|
109
|
+
certainty: linter_format_1.LintingResultCertainty.Uncertain,
|
|
109
110
|
filePath: node.content.str,
|
|
110
111
|
range: node.info.fullRange ?? node.location,
|
|
111
112
|
quickFix: buildQuickFix(node, node.content.str, wd)
|
|
@@ -115,12 +116,12 @@ exports.ABSOLUTE_PATH = {
|
|
|
115
116
|
return [];
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
|
-
else if (element.
|
|
119
|
-
const result = element.
|
|
119
|
+
else if ((0, search_enrichers_1.enrichmentContent)(element, search_enrichers_1.Enrichment.QueryData)) {
|
|
120
|
+
const result = queryResults[(0, search_enrichers_1.enrichmentContent)(element, search_enrichers_1.Enrichment.QueryData).query];
|
|
120
121
|
const mappedStrings = result.readData.filter(r => r.source !== dependencies_query_format_1.Unknown && (0, strings_1.isAbsolutePath)(r.source, regex)).map(r => {
|
|
121
122
|
const elem = data.normalize.idMap.get(r.nodeId);
|
|
122
123
|
return {
|
|
123
|
-
certainty: linter_format_1.
|
|
124
|
+
certainty: linter_format_1.LintingResultCertainty.Certain,
|
|
124
125
|
filePath: r.source,
|
|
125
126
|
range: elem?.info.fullRange ?? elem?.location ?? (0, range_1.rangeFrom)(-1, -1, -1, -1),
|
|
126
127
|
quickFix: buildQuickFix(elem, r.source, wd)
|
|
@@ -141,7 +142,7 @@ exports.ABSOLUTE_PATH = {
|
|
|
141
142
|
const strings = handler ? handler(data.dataflow.graph, dfNode, data.config) : [];
|
|
142
143
|
if (strings) {
|
|
143
144
|
return strings.filter(s => (0, strings_1.isAbsolutePath)(s, regex)).map(str => ({
|
|
144
|
-
certainty: linter_format_1.
|
|
145
|
+
certainty: linter_format_1.LintingResultCertainty.Uncertain,
|
|
145
146
|
filePath: str,
|
|
146
147
|
range: node.info.fullRange ?? node.location ?? (0, range_1.rangeFrom)(-1, -1, -1, -1)
|
|
147
148
|
}));
|
|
@@ -163,6 +164,8 @@ exports.ABSOLUTE_PATH = {
|
|
|
163
164
|
name: 'Absolute Paths',
|
|
164
165
|
description: 'Checks whether file paths are absolute.',
|
|
165
166
|
tags: [linter_tags_1.LintingRuleTag.Robustness, linter_tags_1.LintingRuleTag.Reproducibility, linter_tags_1.LintingRuleTag.Smell, linter_tags_1.LintingRuleTag.QuickFix],
|
|
167
|
+
// checks all found paths for whether they're absolute to ensure correctness, but doesn't handle non-constant paths so not all will be returned
|
|
168
|
+
certainty: linter_format_1.LintingRuleCertainty.BestEffort,
|
|
166
169
|
defaultConfig: {
|
|
167
170
|
include: {
|
|
168
171
|
constructed: true,
|