Skip to content

Commit

Permalink
Make some comments more descriptive
Browse files Browse the repository at this point in the history
  • Loading branch information
CaspianA1 committed Jul 12, 2024
1 parent ee447db commit 1dca8cd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dbos-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type GlobalTools = {eslintContext: EslintContext, parserServices: ParserServices

type ErrorMessageIdWithFormatData = [string, Record<string, unknown>];

// This returns `undefined` for no error; otherwise, it returns a just key to the `errorMessages` map, or a key paired with info for error string formatting
// This returns `undefined` for no error; otherwise, it returns a key to the `errorMessages` map, or a key paired with info for error string formatting
type ErrorChecker = (node: Node, fnDecl: FnDecl, isLocal: (name: string) => boolean) => string | ErrorMessageIdWithFormatData | undefined;

////////// These are some shared values used throughout the code
Expand Down Expand Up @@ -77,7 +77,7 @@ function makeErrorMessageSet(): Map<string, string> {
const makeDateMessage = (bannedCall: string) => `Calling ${bannedCall} is banned \
(consider using \`@dbos-inc/communicator-datetime\` for consistency and testability)`;

// TODO: update this message if more types are added in the future to `deterministicDecorators` or `awaitableTypes`
// TODO: update this message if more types are added in the future to the `Workflow` key in `decoratorSetErrorCheckerMapping` below, or `awaitableTypes` above
const awaitMessage = `The enclosing workflow makes an asynchronous call to a non-DBOS function. \
Please verify that this call is deterministic or it may lead to non-reproducible behavior`;

Expand Down Expand Up @@ -414,8 +414,8 @@ const isSqlInjection: ErrorChecker = (node, fnDecl, _isLocal) => {

// Note: a workflow can never be a transaction, so no need to worry about overlap here
const decoratorSetErrorCheckerMapping: Map<Set<string>, ErrorChecker[]> = new Map([
[new Set(["Transaction"]), [isSqlInjection]],
[new Set(["Workflow"]), [mutatesGlobalVariable, callsBannedFunction, awaitsOnNotAllowedType]]
[new Set(["Transaction"]), [isSqlInjection]], // Checking for SQL injection here
[new Set(["Workflow"]), [mutatesGlobalVariable, callsBannedFunction, awaitsOnNotAllowedType]] // Checking for nondeterminism here
]);

function analyzeFunction(fnDecl: FnDecl) {
Expand Down

0 comments on commit 1dca8cd

Please sign in to comment.