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

refactor: resolve eslint warnings (max-statements, complexity) - src/lib/assets/index.ts #1497

Merged
merged 7 commits into from
Dec 4, 2024

Conversation

btlghrants
Copy link
Collaborator

Describe what should be investigated or refactored

Refactor of src/lib/assets/index.ts to reduce complexity warnings:

/pepr/src/lib/assets/index.ts
  82:23  warning  Async method 'generateHelmChart' has a complexity of 12. Maximum allowed is 10        complexity
  82:23  warning  Async method 'generateHelmChart' has too many statements (58). Maximum allowed is 20  max-statements

Additional context

In support of #1248

@btlghrants btlghrants self-assigned this Dec 3, 2024
Copy link

codecov bot commented Dec 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.12%. Comparing base (b75ac42) to head (102ab83).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1497   +/-   ##
=======================================
  Coverage   79.12%   79.12%           
=======================================
  Files          39       39           
  Lines        1720     1720           
  Branches      388      404   +16     
=======================================
  Hits         1361     1361           
+ Misses        357      330   -27     
- Partials        2       29   +27     

see 7 files with indirect coverage changes

@btlghrants btlghrants added this to the v0.41.0 milestone Dec 3, 2024
@btlghrants btlghrants changed the title refactor: complexity - src/lib/assets/index.ts refactor: resolve eslint warnings (max-statements, complexity) - src/lib/assets/index.ts Dec 3, 2024
@btlghrants btlghrants force-pushed the 1495_complexity_lib_assets_index branch from b5ff99a to be5f3a5 Compare December 4, 2024 04:12
@btlghrants
Copy link
Collaborator Author

btlghrants commented Dec 4, 2024

Got all the complexity warnings fixed and shrunk number of statements to just one more than the limit where I then stopped because any further statement squashing would have made the function more difficult to grok.

This method has the (rather large) responsibility for laying out files on disk in a format that it doesn't own -- a helm chart's expected structure -- and that feels rather larger in scope than the max-statements eslint rule was intended to apply to, so... after I shrank the function as much as I thought was advisable I added a comment-based config to tell eslint that this method is (likely) as minimal as it's going to get.

@btlghrants btlghrants marked this pull request as ready for review December 4, 2024 04:29
@btlghrants btlghrants requested a review from a team as a code owner December 4, 2024 04:29
src/lib/assets/index.ts Outdated Show resolved Hide resolved
src/lib/assets/index.ts Outdated Show resolved Hide resolved
src/lib/assets/index.ts Outdated Show resolved Hide resolved
src/lib/assets/index.ts Outdated Show resolved Hide resolved
src/lib/assets/index.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@samayer12 samayer12 left a comment

Choose a reason for hiding this comment

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

Discussion points have been resolved, good work on addressing some complex code!

@samayer12 samayer12 added this pull request to the merge queue Dec 4, 2024
Merged via the queue into main with commit ab8348b Dec 4, 2024
46 checks passed
@samayer12 samayer12 deleted the 1495_complexity_lib_assets_index branch December 4, 2024 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants