Skip to content

Commit

Permalink
chore: increase max line length (#970)
Browse files Browse the repository at this point in the history
  • Loading branch information
rgwozdz authored Apr 12, 2024
1 parent 9a0ebda commit e215a22
Show file tree
Hide file tree
Showing 176 changed files with 1,887 additions and 4,337 deletions.
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"trailingComma": "all",
"tabWidth": 2,
"useTabs": false,
"endOfLine": "lf"
"endOfLine": "lf",
"printWidth": 100
}
2 changes: 1 addition & 1 deletion ci/clean-coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ const shell = require('shelljs');

shell.rm('-rf', './**/.coverage');
shell.rm('-rf', '.coverage');
shell.rm('.branch-coverage-changes.md');
shell.rm('.branch-coverage-changes.md');
25 changes: 5 additions & 20 deletions ci/format-branch-coverage-changes.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,16 @@ const rows = Object.entries(coverageChangesSummary)
const masterCoverage = coverageSummary[packageFilePath];
return [
packageFilePath,
formatCovComparison(
changesCoverage.statements.pct,
masterCoverage?.statements?.pct || 0,
),
formatCovComparison(
changesCoverage.branches.pct,
masterCoverage?.branches?.pct || 0,
),
formatCovComparison(
changesCoverage.functions.pct,
masterCoverage?.functions?.pct || 0,
),
formatCovComparison(
changesCoverage.lines.pct,
masterCoverage?.lines?.pct || 0,
),
formatCovComparison(changesCoverage.statements.pct, masterCoverage?.statements?.pct || 0),
formatCovComparison(changesCoverage.branches.pct, masterCoverage?.branches?.pct || 0),
formatCovComparison(changesCoverage.functions.pct, masterCoverage?.functions?.pct || 0),
formatCovComparison(changesCoverage.lines.pct, masterCoverage?.lines?.pct || 0),
];
});

const headers = ['File Path', 'Statements', 'Branches', 'Functions', 'Lines'];

const table = json2md([
{ h2: 'Coverage Report (change vs master)' },
{ table: { headers, rows } },
]);
const table = json2md([{ h2: 'Coverage Report (change vs master)' }, { table: { headers, rows } }]);

const alignedTable = table.replace(
'| --------- | ---------- | -------- | --------- | ----- |',
Expand Down
6 changes: 3 additions & 3 deletions ci/format-coverage-summary.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const { writeFileSync } = require('fs');
const _ = require('lodash');
const coverageSummary = require('../.coverage_json/coverage-summary.json');
const formattedSummary = _.mapKeys(coverageSummary, ( value, key) => {
if(key === 'total') {
const formattedSummary = _.mapKeys(coverageSummary, (value, key) => {
if (key === 'total') {
return key;
}
const packagePath = key.split('packages')[1];
return `packages${packagePath}`;
});

writeFileSync('.coverage_json/coverage-summary.json', JSON.stringify(formattedSummary), 'utf8');
writeFileSync('.coverage_json/coverage-summary.json', JSON.stringify(formattedSummary), 'utf8');
6 changes: 3 additions & 3 deletions ci/merge-coverage-changes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ workspaces.forEach((workspace) => {
const package = workspace.split(path.sep).pop();

const coverageDir = path.join('.coverage', context);
const packageCoverageDirectory = path.join(process.cwd(),'.coverage', context);
const packageCoverageDirectory = path.join(process.cwd(), '.coverage', context);

console.log(`Package "${package}":`);

Expand All @@ -30,9 +30,9 @@ workspaces.forEach((workspace) => {

function getCmd(package, coverageDir) {
const destination = path.join('..', '..', coverageDir);
if(package === 'output-geoservices') {
if (package === 'output-geoservices') {
return `cp ${coverageDir}/coverage-final.json ${destination}/output-geoservices.json > /dev/null`;
}

return `npx nyc merge ${coverageDir}/analysis ${destination}/${package}.json > /dev/null`;
}
}
45 changes: 25 additions & 20 deletions ci/run-coverage-on-branch-changes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,29 @@ const _ = require('lodash');

const { workspaces } = require('../package.json');

async function execute () {
async function execute() {
for (let i = 0; i < workspaces.length; i++) {
const workspace = workspaces[i];
process.chdir(workspace);
const package = workspace.split(path.sep).pop();

const {files} = await git().diffSummary(['--name-only', '--relative', 'origin/master']);
const { files } = await git().diffSummary(['--name-only', '--relative', 'origin/master']);

const srcFiles = files.filter(({ file }) => {
return file.endsWith('.js') && !file.endsWith('spec.js');
}).map(({ file }) => {
return `-n ${file}`;
});
const srcFiles = files
.filter(({ file }) => {
return file.endsWith('.js') && !file.endsWith('spec.js');
})
.map(({ file }) => {
return `-n ${file}`;
});

const testTargetFiles = files.filter(({ file }) => {
return file.startsWith('src') && file.endsWith('spec.js');
}).map(({ file }) => {
return `-n ${file.replace('.spec', '')}`;
});
const testTargetFiles = files
.filter(({ file }) => {
return file.startsWith('src') && file.endsWith('spec.js');
})
.map(({ file }) => {
return `-n ${file.replace('.spec', '')}`;
});

const filesForCoverageCheck = _.uniq([...srcFiles, ...testTargetFiles]);

Expand All @@ -40,13 +44,14 @@ async function execute () {
}
}

execute().then(() => {
process.exit();
}).catch(error => {
console.error(error);
process.exit(1);
});

execute()
.then(() => {
process.exit();
})
.catch((error) => {
console.error(error);
process.exit(1);
});

function getCovCmd(package, srcFiles) {
if (package === 'output-geoservices') {
Expand All @@ -62,4 +67,4 @@ function getTestCmd(package) {
}

return 'npm run test > /dev/null';
}
}
4 changes: 3 additions & 1 deletion ci/run-report-on-branch-changes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ if (!fs.existsSync('.coverage/changes')) {
return;
}

shell.exec('nyc report --temp-dir=.coverage/changes --reporter=json-summary --report-dir=.coverage_changes_json');
shell.exec(
'nyc report --temp-dir=.coverage/changes --reporter=json-summary --report-dir=.coverage_changes_json',
);
5 changes: 2 additions & 3 deletions ci/run-test-coverage-analysis.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

const { workspaces } = require('../package.json');
const shell = require('shelljs');
const path = require('path');
Expand All @@ -12,7 +11,7 @@ workspaces.forEach((workspace) => {
const package = workspace.split(path.sep).pop();
console.log(`Package "${package}":`);
process.stdout.write(` - running ${context} test coverage...`);
shell.exec(getCovCmd(package, context));
shell.exec(getCovCmd(package, context));
process.stdout.write('completed.\n');
process.stdout.write(` - generating ${context} test coverage badge...`);
shell.exec(getBadgeCmd(package, context));
Expand Down Expand Up @@ -42,4 +41,4 @@ function getTestCmd(package, context) {
}

return 'npm run test > /dev/null';
}
}
40 changes: 20 additions & 20 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@ const prettier = require('eslint-plugin-prettier');
module.exports = {
languageOptions: {
globals: {
commonjs: true,
es6: true,
mocha: true,
jest: true,
jasmine: true,
node: true,
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
process: 'readonly',
console: 'readonly',
__dirname: 'readonly',
commonjs: true,
es6: true,
mocha: true,
jest: true,
jasmine: true,
node: true,
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
process: 'readonly',
console: 'readonly',
__dirname: 'readonly',
},
parserOptions: {
ecmaVersion: 2022,
},
},
parserOptions: {
ecmaVersion: 2022,
},
},


rules: {
'no-unused-vars': ['error', { ignoreRestSiblings: true }],
'semi': ['error', 'always'],
'prettier/prettier': ['error', {endOfLine: 'auto'}],
semi: ['error', 'always'],
'prettier/prettier': ['error', { endOfLine: 'auto', printWidth: 100 }],
'no-only-tests/no-only-tests': 'error',
//'linebreak-style': ['error', 'unix'],
'max-len': ['error', { code: 100 }],
},
plugins: {
'no-only-tests': noOnlyTests,
'prettier': prettier
prettier: prettier,
},
};
20 changes: 7 additions & 13 deletions packages/core/src/data-provider/extend-controller.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
class DefaultController {}

/**
* We extend all controllers to ensure the following properties exist: this.model, this.routes, this.namespace
* We extend all controllers to ensure the following properties exist:
* this.model, this.routes, this.namespace
*/
module.exports = function extendController(
model,
BaseController = DefaultController,
options,
) {
module.exports = function extendController(model, BaseController = DefaultController, options) {
class Controller extends BaseController {
constructor(model, options) {
super(model, options);
this.model = model;
}
}
const controller = new Controller(model, options);
const controllerEnumerables = Object.keys(BaseController).reduce(
(acc, member) => {
acc[member] = BaseController[member];
return acc;
},
{},
);
const controllerEnumerables = Object.keys(BaseController).reduce((acc, member) => {
acc[member] = BaseController[member];
return acc;
}, {});
Object.assign(controller, controllerEnumerables);

controller.routes = controller.routes || [];
Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/data-provider/extend-controller.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ describe('Tests for create-controller', function () {
it('should use a default namespace when unnamed constructor functions are used', () => {
const mockModel = 'model-test';
const extendedController = extendController(mockModel, function () {});
extendedController.should.have.property(
'namespace',
'UndefinedControllerNamespace',
);
extendedController.should.have.property('namespace', 'UndefinedControllerNamespace');
});
});
30 changes: 8 additions & 22 deletions packages/core/src/data-provider/extend-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ module.exports = function extendModel(
this.#cacheTtl = options.cacheTtl;
this.namespace = namespace;
this.logger = logger;
this.#before = this.#normalizeAndBindMethod(
options.before || beforeNoop,
2,
);
this.#before = this.#normalizeAndBindMethod(options.before || beforeNoop, 2);
this.#after = this.#normalizeAndBindMethod(options.after || afterNoop, 3);
this.#cacheRetrieve = this.#normalizeAndBindMethod(
modelCache?.retrieve || cacheRetrieveNoop,
Expand All @@ -47,9 +44,7 @@ module.exports = function extendModel(
modelCache,
);
this.#getProviderData = this.#normalizeAndBindMethod(this.getData, 2);
this.#getLayer = this.getLayer
? this.#normalizeAndBindMethod(this.getLayer, 2)
: undefined;
this.#getLayer = this.getLayer ? this.#normalizeAndBindMethod(this.getLayer, 2) : undefined;
this.#getCatalog = this.getCatalog
? this.#normalizeAndBindMethod(this.getCatalog, 2)
: undefined;
Expand Down Expand Up @@ -117,9 +112,7 @@ module.exports = function extendModel(
if (!this.#getLayer) {
return this.#handleReturn(
callback,
new Error(
`getLayer() method is not implemented in the ${this.namespace} provider.`,
),
new Error(`getLayer() method is not implemented in the ${this.namespace} provider.`),
);
}

Expand Down Expand Up @@ -156,9 +149,7 @@ module.exports = function extendModel(
if (!this.#getCatalog) {
return this.#handleReturn(
callback,
new Error(
`getCatalog() method is not implemented in the ${this.namespace} provider.`,
),
new Error(`getCatalog() method is not implemented in the ${this.namespace} provider.`),
);
}

Expand Down Expand Up @@ -198,9 +189,7 @@ module.exports = function extendModel(
const providerStream = await this.getStream(req);
return providerStream;
} else {
throw new Error(
'getStream() function is not implemented in the provider.',
);
throw new Error('getStream() function is not implemented in the provider.');
}
}

Expand All @@ -227,9 +216,7 @@ module.exports = function extendModel(
// If provider has auth methods use them, then use auth-module methods, otherwise dummy methods
if (typeof ProviderModel.prototype.authorize !== 'function') {
Model.prototype.authorize =
typeof authModule?.authorize === 'function'
? authModule.authorize
: async () => {};
typeof authModule?.authorize === 'function' ? authModule.authorize : async () => {};
}

if (typeof ProviderModel.prototype.authenticate !== 'function') {
Expand All @@ -245,15 +232,14 @@ module.exports = function extendModel(
logger.warn(
'Use of "authenticationSpecification" is deprecated. It will be removed in a future release.',
);
Model.prototype.authenticationSpecification =
authModule?.authenticationSpecification;
Model.prototype.authenticationSpecification = authModule?.authenticationSpecification;
}

return new Model({ logger, cache }, options);
};

function shouldUseCache(cacheEntry) {
// older cache plugins stored expiry time explicitly; all caches should move to returning empty if expired
// older cache plugins stored expiry time; all should move to returning empty if expired
if (!cacheEntry) {
return false;
}
Expand Down
Loading

0 comments on commit e215a22

Please sign in to comment.