Skip to content

chore: Lint#153

Open
daogrady wants to merge 7 commits into
mainfrom
chore/lint
Open

chore: Lint#153
daogrady wants to merge 7 commits into
mainfrom
chore/lint

Conversation

@daogrady
Copy link
Copy Markdown
Contributor

@daogrady daogrady commented Jun 2, 2026

I noticed a multitude of lint warnings in the current code. This PR addresses most of them.
The only remaining warnings should come from the complexity rule, for which we currently have 11 violations. The most complex function has a whopping complexity of 84 (getSchema)! I am not sure if that means that we should rework the offending functions, or if we should instead remove this rule from the rule set.

@daogrady daogrady changed the title Lint chore: Lint Jun 2, 2026
Comment thread lib/compile/csdl.js
Comment on lines +81 to +82
const schema = this.csdl[name] ?? {};
const qualifier = schema.$Alias ?? name;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes became necessary due to the change from JSON.parse(JSON.stringify) to structuredClone. The former removes all properties with value undefined (which is not a valid JSON value), while the latter preserves them. So iterating over the keys of an object which was freshly cloned via JSON.parse(JSON.stringify) is guaranteed to not have keys pointing to undefined values.

Image

Comment on lines +463 to +473
* @param {object} options
* @param {Paths} options.paths Paths Object to augment
* @param {string} options.prefix Prefix for path
* @param {Array} options.prefixParameters Parameter Objects for prefix
* @param {object} options.element Model element of navigation segment
* @param {object} options.root Root model element
* @param {string} options.sourceName Name of path source
* @param {string} options.targetName Name of path target
* @param {null | TargetRestrictions[]} options.target Target container child of path
* @param {number} options.level Number of navigation segments so far
* @param {string} options.navigationPath Path for finding navigation restrictions
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this family of changes was introduced to satisfy the max-params rule. It also makes the call-sites easier to read, as arguments are now explicitly named.

Comment thread eslint.config.mjs
'max-len': ['off'],
'complexity': ['warn', 15],
'max-params': ['warn', 4],
'no-param-reassign': 'warn',
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have multiple places in which we apply some sanitisation to parameters as first step. I think it makes sense to allow this behaviour. Alternatives would be to either have // eslint-disable-nextlines, or to have constructs like

function foo (myParam) {
  const mySanitisedParam = sanitise(myParam)
}

Both feel odd to me, but I am open to discussing the matter, if removing the no-param-reassign rule is not an option.

@daogrady daogrady marked this pull request as ready for review June 2, 2026 07:44
@daogrady daogrady requested a review from tim-sh June 2, 2026 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant