Skip to content

Commit 54879d2

Browse files
authored
Merge pull request #850 from volodya-lombrozo/838-make-lints-optional
feat(#838): disable linting with --blind flag to improve performance
2 parents d299304 + ca242c6 commit 54879d2

6 files changed

Lines changed: 47 additions & 2 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ There are also commands that help manipulate with XMIR and EO sources
147147
This command line toolkit simply integrates other tools available in
148148
the [@objectionary](https://github.com/objectionary) GitHub organization.
149149

150+
## Linting
151+
152+
There are two ways to work with linting. The `--easy` option enables linting
153+
but ignores warnings, while the `--blind` option completely disables linting.
154+
150155
## How to Test
151156

152157
To execute the project tests, use the following command:

src/commands/lint.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const semver = require('semver');
1717
module.exports = function(opts) {
1818
const extra = [
1919
`-Deo.failOnWarning=${opts.easy ? 'false' : 'true'}`,
20-
`-Deo.skipLinting=${opts.blind ? 'true' : 'false'}`,
2120
];
2221
return elapsed(async (tracked) => {
2322
if (opts.parser.endsWith('-SNAPSHOT') || semver.gte(opts.parser, '0.45.0')) {

src/eoc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ program
9494
.option('-s, --sources <path>', 'Directory with .EO sources', '.')
9595
.option('-t, --target <path>', 'Directory with all generated files', '.eoc')
9696
.option('--easy', 'Ignore "warnings" and only fail if there are "errors" or "critical" errors')
97-
.option('--blind', 'Ignore "warnings," "errors," and "critical" errors')
97+
.option('--blind', 'Disable linting')
9898
.option('--home-tag <version>', 'Git tag in objectionary/home to compile against', tag)
9999
.option('--parser <version>', 'Set the version of EO parser to use', parser)
100100
.option('--latest', 'Use the latest parser version from Maven Central')

src/mvnw.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ module.exports.flags = function (opts) {
5656
`-Deo.generatedDir=${path.resolve(opts.target, 'generated-sources')}`,
5757
`-Deo.placed=${path.resolve(opts.target, 'eo-placed.csv')}`,
5858
`-Deo.placedFormat=csv`,
59+
`-Deo.skipLinting=${opts.blind ? 'true' : 'false'}`,
5960
opts.trackTransformationSteps ? '-Deo.trackTransformationSteps' : '',
6061
];
6162
};
@@ -69,6 +70,7 @@ module.exports.flags = function (opts) {
6970
*/
7071
module.exports.mvnw = function (args, tgt, batch) {
7172
return new Promise((resolve, reject) => {
73+
console.debug(`Running mvnw with arguments: ${args.join(' ')}`);
7274
target = tgt;
7375
phase = args[0];
7476
const home = path.resolve(__dirname, '../mvnw');

test/commands/test_compile.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,25 @@ describe('compile', () => {
9696
]);
9797
assert.ok(stdout.includes('skipped for JavaScript'));
9898
});
99+
it('Skips linting if --blind specified', () => {
100+
const home = path.resolve('temp/test-compile/simple');
101+
fs.rmSync(home, {recursive: true, force: true});
102+
fs.mkdirSync(path.resolve(home, 'src', 'foo', 'bar'), {recursive: true});
103+
fs.writeFileSync(path.resolve(home, 'src/foo/bar/compile3.eo'), simple('compile3'));
104+
const stdout = runSync([
105+
'compile',
106+
'--verbose',
107+
'--blind',
108+
`--parser=${parserVersion}`,
109+
`--home-tag=${homeTag}`,
110+
'-s', path.resolve(home, 'src'),
111+
'-t', path.resolve(home, 'target'),
112+
]);
113+
assert.ok(
114+
stdout.includes('Linting is skipped because eo:skipLinting is TRUE'),
115+
'Linting should be skipped with --blind option'
116+
);
117+
});
99118
});
100119

101120
/**

test/commands/test_lint.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,24 @@ describe('lint', () => {
3535
assert(!fs.existsSync(path.resolve('../../mvnw/target')));
3636
done();
3737
});
38+
it('avoid linting if --blind option is provided', (done) => {
39+
const home = path.resolve('temp/test-lint/simple');
40+
fs.rmSync(home, {recursive: true, force: true});
41+
fs.mkdirSync(path.resolve(home, 'src'), {recursive: true});
42+
fs.writeFileSync(path.resolve(home, 'src/simple.eo'), '# sample\n[] > simple\n');
43+
runSync([
44+
'lint',
45+
'--verbose',
46+
'--blind',
47+
'--track-transformation-steps',
48+
`--parser=${parserVersion}`,
49+
`--home-tag=${homeTag}`,
50+
'-s', path.resolve(home, 'src'),
51+
'-t', path.resolve(home, 'target'),
52+
]);
53+
assert(
54+
!fs.existsSync(path.resolve(home, 'target/3-lint/simple.xmir')),
55+
'Linting should be skipped with --blind option');
56+
done();
57+
});
3858
});

0 commit comments

Comments
 (0)