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

ν4.duplication & high cognitive complexity #4

Closed

Conversation

NouniTheodora
Copy link
Collaborator

Describe the changes you have made here: what, why, ...
Link the issue that will be closed, e.g., "Closes JabRef#333". If your PR closes a koppor issue, link it using its URL, e.g., "Closes JabRef#47".

Mandatory checks

  • I own the copyright of the code submitted and I licence it under the MIT license
  • Change in CHANGELOG.md described in a way that is understandable for the average user (if change is visible to the user)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

…ainability:

- Extracted logic for processing stored file types into processStoredFileTypes method.
- Added reusable methods replaceOrAddType and removeTypeByName to reduce code duplication.
- Improved readability of fromString method by simplifying its structure.
- Eliminated redundant logic in handling removed and modified file types.
…ainability:

- Extracted logic for processing stored file types into processStoredFileTypes method.
- Added reusable methods replaceOrAddType and removeTypeByName to reduce code duplication.
- Improved readability of fromString method by simplifying its structure.
- Eliminated redundant logic in handling removed and modified file types.
…ainability:

- Extracted logic for processing stored file types into processStoredFileTypes method.
- Added reusable methods replaceOrAddType and removeTypeByName to reduce code duplication.
- Improved readability of fromString method by simplifying its structure.
- Eliminated redundant logic in handling removed and modified file types.

Removed unused imports and private fields:
- Deleted an unused import statement in line 19.
- Removed the unused private field 'name' in line 28.
…maintainability:

- Extracted the logic into smaller helper methods (`handlePermutations`, `handleUpdates`, `handleRemovals`, `handleAdditions`) to reduce cognitive complexity.
- Added descriptive comments for better understanding of the code.
- Simplified the structure by avoiding nested conditions and repetitive logic.
- Aligned the method with the Single Responsibility Principle (SRP).

This refactoring reduces the cognitive complexity of the method from 24 to below the allowed threshold (15), as reported by SonarQube.
@NouniTheodora NouniTheodora deleted the ν4.Duplication-&-High-Cognitive-Complexity branch January 16, 2025 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reset of all preferences should be accessible through Options/Preferences Code for icons
2 participants