Skip to content

Commit

Permalink
style: apply automated linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
megalinter-bot committed Oct 10, 2023
1 parent eeda845 commit bdb0a5a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
38 changes: 19 additions & 19 deletions src/language/validation/other/expressions/memberAccesses.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import {SafeDsServices} from "../../../safe-ds-module.js";
import {SdsMemberAccess} from "../../../generated/ast.js";
import {ValidationAcceptor} from "langium";
import {UnknownType} from "../../../typing/model.js";
import { SafeDsServices } from '../../../safe-ds-module.js';
import { SdsMemberAccess } from '../../../generated/ast.js';
import { ValidationAcceptor } from 'langium';
import { UnknownType } from '../../../typing/model.js';

export const CODE_MEMBER_ACCESS_MISSING_NULL_SAFETY = 'member-access/missing-null-safety';

export const memberAccessMustBeNullSafeIfReceiverIsNullable =
(services: SafeDsServices) =>
(node: SdsMemberAccess, accept: ValidationAcceptor): void => {
if (node.isNullSafe) {
return;
}
(node: SdsMemberAccess, accept: ValidationAcceptor): void => {
if (node.isNullSafe) {
return;
}

const receiverType = services.types.TypeComputer.computeType(node.receiver);
if (receiverType === UnknownType) {
return;
}
const receiverType = services.types.TypeComputer.computeType(node.receiver);
if (receiverType === UnknownType) {
return;
}

if (receiverType.isNullable) {
accept('error', "The receiver can be null so a safe access must be used.", {
node,
code: CODE_MEMBER_ACCESS_MISSING_NULL_SAFETY,
});
}
};
if (receiverType.isNullable) {
accept('error', 'The receiver can be null so a safe access must be used.', {
node,
code: CODE_MEMBER_ACCESS_MISSING_NULL_SAFETY,
});
}
};
4 changes: 2 additions & 2 deletions src/language/validation/safe-ds-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ import {
callableTypeResultsMustNotBeAnnotated,
lambdaParametersMustNotBeAnnotated,
} from './other/declarations/annotationCalls.js';
import {memberAccessMustBeNullSafeIfReceiverIsNullable} from "./other/expressions/memberAccesses.js";
import { memberAccessMustBeNullSafeIfReceiverIsNullable } from './other/expressions/memberAccesses.js';

/**
* Register custom validation checks.
Expand Down Expand Up @@ -122,7 +122,7 @@ export const registerValidationChecks = function (services: SafeDsServices) {
SdsLambda: [lambdaParametersMustNotBeAnnotated, lambdaParameterMustNotHaveConstModifier],
SdsMemberAccess: [
memberAccessMustBeNullSafeIfReceiverIsNullable(services),
memberAccessNullSafetyShouldBeNeeded(services)
memberAccessNullSafetyShouldBeNeeded(services),
],
SdsModule: [moduleDeclarationsMustMatchFileKind, moduleWithDeclarationsMustStatePackage],
SdsNamedType: [
Expand Down

0 comments on commit bdb0a5a

Please sign in to comment.