Quality refactoring #7
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces several improvements focused on code quality, error handling, and robustness across the codebase. The most significant changes include replacing direct
System.err.println()calls with a proper logging framework (SLF4J), standardizing null handling and exception policies, delegating resource URL resolution to a single utility method, and adding headless environment detection to prevent crashes in non-GUI environments.Logging and Error Handling Improvements:
System.err.println()andprintStackTrace()calls ingi-fx/InOut.groovy,gi-fx/Viewer.groovy,gi-swing/InOut.groovy, andgi-console/InOut.groovywith SLF4J logging calls (log.warn,log.error). This provides consistent, configurable logging and better error reporting. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16]gi-common/build.gradleto enable logging support throughout the project.Code Quality and Refactoring:
AbstractInOut.getResourceUrl()to delegate toFileUtils.getResourceUrl(), eliminating code duplication and centralizing resource lookup logic.TODO.mdroadmap to mark logging, duplication removal, headless detection, and null handling standardization as completed. [1] [2]Robustness and Environment Detection:
gi-fx/InOut.groovyandgi-swing/InOut.groovy. These modules now throwUnsupportedOperationExceptionif instantiated in a headless environment, preventing runtime crashes and providing clear guidance to use the console version instead. [1] [2]API Documentation and Policy Standardization:
GuiInteraction.groovyinterface documentation to clearly specify null handling and exception policies for all methods, favoring exceptions for invalid input and null returns only for user cancellation or missing resources. Also updated method signatures and documentation to reflect these policies. [1] [2]