Skip to content

Conversation

@elamperti
Copy link
Owner

Summary

  • remove lodash get calls across the project
  • use optional chaining and nullish coalescing instead
  • update tests for new number-based totalPages

Testing

  • yarn test:unit

https://chatgpt.com/codex/tasks/task_e_6840634bae6c83289d49d6c4be8f057b

@elamperti elamperti changed the title Refactor lodash get usage Remove lodash.get() calls Jun 16, 2025
@elamperti elamperti force-pushed the codex/remove-lodash-get-usage branch from 9e31701 to 40c2b5f Compare June 26, 2025 19:38
@codecov
Copy link

codecov bot commented Jun 26, 2025

Codecov Report

Attention: Patch coverage is 54.16667% with 22 lines in your changes missing coverage. Please review.

Project coverage is 19.74%. Comparing base (1886dac) to head (e666b34).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...s/clients/api/transformers/settings.transformer.ts 12.50% 7 Missing ⚠️
src/domains/scrobbleUser/ScrobbleUserResults.tsx 0.00% 3 Missing ⚠️
src/utils/axios.ts 0.00% 3 Missing ⚠️
src/components/ScrobbleItem/ScrobbleItem.tsx 0.00% 2 Missing ⚠️
...rc/domains/scrobbleAlbum/partials/AlbumResults.tsx 0.00% 2 Missing ⚠️
src/store/reducers/scrobbleReducer.ts 0.00% 2 Missing ⚠️
src/domains/scrobbleSong/SongForm.tsx 0.00% 1 Missing ⚠️
src/utils/clients/lastfm/methods/trackGetInfo.ts 0.00% 1 Missing ⚠️
...m/transformers/albumGetInfoResponse.transformer.ts 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
...cogs/transformers/topAlbumsResponse.transformer.ts 90.90% <100.00%> (-0.40%) ⬇️
...discogs/transformers/tracksResponse.transformer.ts 97.67% <100.00%> (ø)
...fm/transformers/albumSearchResponse.transformer.ts 95.45% <100.00%> (-0.20%) ⬇️
...stfm/transformers/topAlbumsResponse.transformer.ts 95.23% <100.00%> (-0.22%) ⬇️
.../lastfm/transformers/tracksResponse.transformer.ts 96.29% <100.00%> (ø)
...nts/lastfm/transformers/userProfile.transformer.ts 100.00% <100.00%> (ø)
...astfm/transformers/userRecentTracks.transformer.ts 100.00% <100.00%> (ø)
src/domains/scrobbleSong/SongForm.tsx 10.23% <0.00%> (-0.24%) ⬇️
src/utils/clients/lastfm/methods/trackGetInfo.ts 94.44% <0.00%> (-5.56%) ⬇️
...m/transformers/albumGetInfoResponse.transformer.ts 95.23% <66.66%> (-4.77%) ⬇️
... and 6 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cypress
Copy link

cypress bot commented Jun 26, 2025

Open Scrobbler    Run #54

Run Properties:  status check passed Passed #54  •  git commit 861fdb8bfa ℹ️: Merge e666b3480e3220d578b6ce339e0ddc792598ad29 into 1886dacfafc12ed0d5c7f33e6b53...
Project Open Scrobbler
Branch Review codex/remove-lodash-get-usage
Run status status check passed Passed #54
Run duration 02m 41s
Commit git commit 861fdb8bfa ℹ️: Merge e666b3480e3220d578b6ce339e0ddc792598ad29 into 1886dacfafc12ed0d5c7f33e6b53...
Committer Enrico Lamperti
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 3
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 74
View all changes introduced in this branch ↗︎

@elamperti elamperti marked this pull request as ready for review June 26, 2025 20:37
@elamperti elamperti requested a review from Copilot June 26, 2025 20:37
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes all instances of lodash.get (and related calls) across the project in favor of optional chaining and nullish coalescing, while also updating tests for new number-based totalPages.

  • Replaces lodash.get/hasIn calls with native optional chaining in several transformer files.
  • Updates tests and type conversions (e.g., totalPages conversion in userRecentTracks transformer).
  • Cleans up similar patterns in API calls, reducer logic, and component error handling.

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/utils/clients/lastfm/transformers/userRecentTracks.transformer.ts Removed lodash.get calls and replaced them with optional chaining and explicit type conversion for totalPages.
src/utils/clients/lastfm/transformers/userRecentTracks.transformer.test.ts Adjusted test expectations to reflect numeric totalPages.
src/utils/clients/lastfm/transformers/userProfile.transformer.ts Updated the avatar transformation to only process arrays.
src/utils/clients/lastfm/transformers/tracksResponse.transformer.ts Replaced lodash.get with optional chaining for rawTrackList and album assignment.
src/utils/clients/lastfm/transformers/topAlbumsResponse.transformer.ts; albumSearchResponse.transformer.ts; albumGetInfoResponse.transformer.ts; trackGetInfo.ts Similar changes applied for optional chaining in data access.
src/utils/clients/discogs/transformers/*.ts Removed lodash.get calls; applied optional chaining updates in tracks and topAlbums transformers.
src/utils/clients/api/transformers/settings.transformer.ts Replaced lodash.get calls with optional chaining and updated function signature.
src/utils/axios.ts Replaced lodash.get with optional chaining for error handling improvements.
src/store/reducers/scrobbleReducer.ts Updated error message extraction via optional chaining.
src/domains/scrobbleUser/ScrobbleUserResults.tsx; SongForm.tsx; AlbumResults.tsx; ScrobbleItem.tsx Removed lodash.get in favor of native optional chaining for improved readability and type safety.
Comments suppressed due to low confidence (2)

src/utils/clients/api/transformers/settings.transformer.ts:3

  • Consider using a more specific type such as Partial instead of any for the settings parameter to improve type safety.
export function settingsTransformer(settings: any = {}): Settings {

src/utils/clients/discogs/transformers/tracksResponse.transformer.ts:44

  • [nitpick] Review the fallback logic and confirm that defaulting to an empty string when no artist name is available is the intended behavior.
        artist: sanitizeArtistName((track.artists?.[0]?.name ?? options?.artist) || ''),

@elamperti elamperti merged commit 50b2b49 into main Jun 26, 2025
6 checks passed
@elamperti elamperti deleted the codex/remove-lodash-get-usage branch June 26, 2025 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants