From eb45e34b70562c72b2e1e07d0fd6fa13ad9940ab Mon Sep 17 00:00:00 2001 From: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com> Date: Thu, 12 Oct 2023 17:57:32 +0000 Subject: [PATCH] style: apply automated linter fixes --- src/language/helpers/safe-ds-node-mapper.ts | 4 +++- .../other/statements/assignments.ts | 24 ++++++++++--------- src/language/validation/safe-ds-validator.ts | 8 +++---- src/language/validation/types.ts | 19 +++++++++------ 4 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/language/helpers/safe-ds-node-mapper.ts b/src/language/helpers/safe-ds-node-mapper.ts index 84f5e6f92..e2ca1df83 100644 --- a/src/language/helpers/safe-ds-node-mapper.ts +++ b/src/language/helpers/safe-ds-node-mapper.ts @@ -6,7 +6,9 @@ import { isSdsAssignment, isSdsBlock, isSdsCall, - isSdsCallable, isSdsClass, isSdsEnumVariant, + isSdsCallable, + isSdsClass, + isSdsEnumVariant, isSdsNamedType, isSdsReference, isSdsSegment, diff --git a/src/language/validation/other/statements/assignments.ts b/src/language/validation/other/statements/assignments.ts index 23f3b233e..5d0d6e0e9 100644 --- a/src/language/validation/other/statements/assignments.ts +++ b/src/language/validation/other/statements/assignments.ts @@ -1,8 +1,8 @@ -import {isSdsCall, isSdsPipeline, SdsAssignment, SdsYield} from '../../../generated/ast.js'; +import { isSdsCall, isSdsPipeline, SdsAssignment, SdsYield } from '../../../generated/ast.js'; import { getContainerOfType, ValidationAcceptor } from 'langium'; import { SafeDsServices } from '../../../safe-ds-module.js'; -import {abstractResultsOrEmpty, assigneesOrEmpty} from '../../../helpers/nodeProperties.js'; -import {pluralize} from "../../../helpers/stringUtils.js"; +import { abstractResultsOrEmpty, assigneesOrEmpty } from '../../../helpers/nodeProperties.js'; +import { pluralize } from '../../../helpers/stringUtils.js'; export const CODE_ASSIGNMENT_IMPLICITLY_IGNORED_RESULT = 'assignment/implicitly-ignored-result'; export const CODE_ASSIGMENT_NOTHING_ASSIGNED = 'assignment/nothing-assigned'; @@ -25,25 +25,27 @@ export const assignmentShouldNotImplicitlyIgnoreResult = (services: SafeDsServic const nodeMapper = services.helpers.NodeMapper; return (node: SdsAssignment, accept: ValidationAcceptor): void => { - const expression = node.expression + const expression = node.expression; if (!isSdsCall(expression)) { - return + return; } - const assignees = assigneesOrEmpty(node) - const callable = nodeMapper.callToCallableOrUndefined(expression) - const results = abstractResultsOrEmpty(callable) + const assignees = assigneesOrEmpty(node); + const callable = nodeMapper.callToCallableOrUndefined(expression); + const results = abstractResultsOrEmpty(callable); if (results.length > assignees.length) { - const kind = pluralize(results.length - assignees.length, 'result') - const names = results.slice(assignees.length).map(result => `'${result.name}'`).join(', ') + const kind = pluralize(results.length - assignees.length, 'result'); + const names = results + .slice(assignees.length) + .map((result) => `'${result.name}'`) + .join(', '); accept('warning', `The assignment implicitly ignores the ${kind} ${names}.`, { node, code: CODE_ASSIGNMENT_IMPLICITLY_IGNORED_RESULT, }); } - }; }; diff --git a/src/language/validation/safe-ds-validator.ts b/src/language/validation/safe-ds-validator.ts index 13bb78add..afe6d4775 100644 --- a/src/language/validation/safe-ds-validator.ts +++ b/src/language/validation/safe-ds-validator.ts @@ -40,7 +40,8 @@ import { yieldMustNotBeUsedInPipeline, } from './other/statements/assignments.js'; import { - attributeMustHaveTypeHint, callReceiverMustBeCallable, + attributeMustHaveTypeHint, + callReceiverMustBeCallable, namedTypeMustSetAllTypeParameters, parameterMustHaveTypeHint, resultMustHaveTypeHint, @@ -126,10 +127,7 @@ export const registerValidationChecks = function (services: SafeDsServices) { SdsArgumentList: [argumentListMustNotHavePositionalArgumentsAfterNamedArguments], SdsAttribute: [attributeMustHaveTypeHint], SdsBlockLambda: [blockLambdaMustContainUniqueNames], - SdsCall: [ - callArgumentListShouldBeNeeded(services), - callReceiverMustBeCallable(services), - ], + SdsCall: [callArgumentListShouldBeNeeded(services), callReceiverMustBeCallable(services)], SdsCallableType: [ callableTypeMustContainUniqueNames, callableTypeMustNotHaveOptionalParameters, diff --git a/src/language/validation/types.ts b/src/language/validation/types.ts index b44007ddb..0e49bba60 100644 --- a/src/language/validation/types.ts +++ b/src/language/validation/types.ts @@ -1,8 +1,13 @@ import { getContainerOfType, ValidationAcceptor } from 'langium'; import { isSdsAnnotation, - isSdsCallable, isSdsClass, - isSdsLambda, isSdsMemberAccess, isSdsPipeline, isSdsReference, isSdsSchema, + isSdsCallable, + isSdsClass, + isSdsLambda, + isSdsMemberAccess, + isSdsPipeline, + isSdsReference, + isSdsSchema, SdsAttribute, SdsCall, SdsNamedType, @@ -26,17 +31,17 @@ export const callReceiverMustBeCallable = (services: SafeDsServices) => { const nodeMapper = services.helpers.NodeMapper; return (node: SdsCall, accept: ValidationAcceptor): void => { - let receiver = node.receiver + let receiver = node.receiver; if (isSdsMemberAccess(receiver)) { - receiver = receiver.member + receiver = receiver.member; } if (isSdsReference(receiver)) { - const target = receiver.target.ref + const target = receiver.target.ref; // We already report other errors at this position in those cases if (!target || isSdsAnnotation(target) || isSdsPipeline(target) || isSdsSchema(target)) { - return + return; } } @@ -47,7 +52,7 @@ export const callReceiverMustBeCallable = (services: SafeDsServices) => { code: CODE_TYPE_CALLABLE_RECEIVER, }); } else if (isSdsClass(callable) && !callable.parameterList) { - accept('error', "Cannot instantiate a class that has no constructor.", { + accept('error', 'Cannot instantiate a class that has no constructor.', { node: node.receiver, code: CODE_TYPE_CALLABLE_RECEIVER, });