Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find-dead-code script exception do not work for variable declarations #1222

Closed
shauke opened this issue Jul 20, 2022 · 0 comments · Fixed by #1273
Closed

find-dead-code script exception do not work for variable declarations #1222

shauke opened this issue Jul 20, 2022 · 0 comments · Fixed by #1273
Assignees
Labels
bug Something isn't working
Milestone

Comments

@shauke
Copy link
Collaborator

shauke commented Jul 20, 2022

Actual Behavior

Running the find-dead-code script would fail for the following two variable definitions even though they are supposed to be exempt from the scripts testing.

// not-dead-code
export const reservedCharactersRegEx = /[ &\(\)=]/g;

https://github.com/intershop/intershop-pwa/blob/develop/src/app/core/utils/routing.ts#L31-L32

// not-dead-code
export const storeDevtoolsModule: unknown[] = [];

https://github.com/intershop/intershop-pwa/blob/develop/src/app/core/store/store-devtools.module.production.ts#L1-L2

We currently have a workaround in place that exempts the whole files from checking for dead code. This should not be necessary.
https://github.com/intershop/intershop-pwa/blob/develop/scripts/find-dead-code.ts#L7

Expected Behavior

Running the find-dead-code script should result in no errors with this configuration:

const fileExceptionsRegex = /\/src\/environments\//;

Steps to Reproduce the Bug

  • Change the fileExceptionsRegex in \scripts\find-dead-code.ts to
const fileExceptionsRegex = /\/src\/environments\//;
  • Run
npx ts-node scripts/find-dead-code.ts

Additional Context, like Screenshots, Log File Snippets etc.

For some reason the logic of

  const ignoreComment = node.getPreviousSiblingIfKind(SyntaxKind.SingleLineCommentTrivia);
  if (ignoreComment?.getText().includes('not-dead-code')) {
    return;
  }

does not apply to the two mentioned const declarations.

AB#78338

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants