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 and enhance config file handling logic #39

Merged
merged 2 commits into from
Aug 24, 2024

Conversation

mitsuki31
Copy link
Owner

Overview

This pull request refactors the logic around configuration file handling and updates the related documentation to improve code maintainability and clarity.

Changes Made

Refactors

  • Improved the resolveConfig function:
    • Now sets the file parameter to 'unknown' only if it is null or not a string.
    • Fixed an issue where the file was being resolved to 'unknown' even when it was a valid string.
  • Simplified audioConverterOptions assignment:
    • Removed unnecessary default initialization to empty objects.
  • Refined the parseConfig function:
    • Uses require() exclusively for .cjs and .json files.
    • Uses import() for other extensions, streamlining the logic.
    • Removed redundant error handling specific to ESM module imports.
  • Exported configChecker function to ensure consistency across the module.

Documentation Updates

  • Added precise JSDoc comments for improved clarity on types and functionality.
  • Updated visibility tags to @package for better encapsulation.
  • Improved parameter types and return types in the documentation for consistency.
  • Enhanced cross-references in JSDoc to improve navigation and clarity.

Impact

  • Enhances the maintainability and readability of the configuration file handling code.
  • Improves encapsulation and clarity through better documentation.

- Improved the logic in `resolveConfig` to set the `file` parameter to 'unknown' if it is null or not a string. This also fixed a logic issue where the 'file' resolved to 'unknown' even it is a string.
- Simplified `audioConverterOptions` assignment by removing unnecessary defaulting to empty objects.
- Refined `parseConfig` to only use `require()` for '.cjs' and '.json' extensions, and `import()` for other cases.
- Removed redundant error handling for ESM module imports.
- Added `configChecker` to module exports for consistency.
- Added and refined JSDoc comments with more precise types and descriptions.
- Updated function and variable visibility tags to `@package` for improved encapsulation.
- Enhanced the clarity of parameter types and return types in the documentation.
- Improved cross-references within the JSDoc comments for consistency.
@mitsuki31 mitsuki31 added refactor Refactor and enhancement changes bugfix Fixes any issue and bug minor Minor changes labels Aug 24, 2024
@mitsuki31 mitsuki31 self-assigned this Aug 24, 2024
Copy link

codecov bot commented Aug 24, 2024

Codecov Report

Attention: Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.

Project coverage is 42.75%. Comparing base (238b15b) to head (07b2290).
Report is 4 commits behind head on master.

Files Patch % Lines
lib/config.js 71.42% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #39      +/-   ##
==========================================
+ Coverage   42.54%   42.75%   +0.20%     
==========================================
  Files           7        7              
  Lines         409      407       -2     
==========================================
  Hits          174      174              
+ Misses        235      233       -2     
Flag Coverage Δ
Ubuntu 42.75% <71.42%> (+0.20%) ⬆️
Windows 42.75% <71.42%> (+0.20%) ⬆️
macOS 42.75% <71.42%> (+0.20%) ⬆️
unittests 42.75% <71.42%> (+0.20%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mitsuki31 mitsuki31 merged commit 3a66580 into master Aug 24, 2024
14 checks passed
@mitsuki31 mitsuki31 deleted the refactor/enhance-config-file-handling-logic branch August 24, 2024 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Fixes any issue and bug minor Minor changes refactor Refactor and enhancement changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant