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

Eliminates critical Cognitive Complexity issue in Card Builder component as detected by SonarCloud #4829

Merged
merged 2 commits into from
Oct 5, 2023

Conversation

ddubson
Copy link
Contributor

@ddubson ddubson commented Oct 3, 2023

Eliminates Cognitive Complexity issue as detected by SonarCloud as a code smell of Critical severity.

Changes

  • Introduces vitest library for executing unit tests. Added npm test to GH Actions for Typescript checking, however running of the test suite may be a new workflow altogether. To reduce the amount of changes, the test suite execution is tacked on to an existing Action.
  • Extract getDesiredAspect and getPostersPerRow functions out of cardBuilder.js component. The new file cardBuilderUtils.js may not have the best name -- this can be renamed as needed.
  • Unit test entirety of both extracted functions
  • Refactor functions to reduce cognitive complexity as per SonarCloud detected issue.

Issues

Fixes gh-4828

https://sonarcloud.io/issues?resolved=false&open=AYry7wqGV85IQSFBo_VD

@ddubson ddubson requested review from a team as code owners October 3, 2023 14:40
@ddubson ddubson force-pushed the ddubson/cards-html-gen-smell branch 2 times, most recently from 6b7443b to a45556b Compare October 3, 2023 19:37
@thornbill thornbill added the cleanup Cleanup of legacy code or code smells label Oct 4, 2023
Adds two new npm scripts:

- 'test' - runs test suite once and exits
- 'test:watch' - runs test suite perpetually.

Any file suffixed with '.test.[js|ts]' is considered a test suite
@ddubson ddubson force-pushed the ddubson/cards-html-gen-smell branch from a45556b to 293fddf Compare October 5, 2023 13:27
@ddubson ddubson force-pushed the ddubson/cards-html-gen-smell branch from 293fddf to d77d69b Compare October 5, 2023 13:42
@sonarcloud
Copy link

sonarcloud bot commented Oct 5, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
4.1% 4.1% Duplication

@thornbill thornbill merged commit f7507fb into jellyfin:master Oct 5, 2023
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Cleanup of legacy code or code smells
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cognitive Complexity issue in CardBuilder component (SonarCloud detected)
2 participants