-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[java] simplify strings processing #15309
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
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||
|
@mk868 review please |
I don't have permission to approve PRs in this repository. |
asolntsev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this 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 pull request aims to simplify string processing in Java code by replacing verbose patterns with more readable alternatives. The changes include replacing "".equals(string) with string.isEmpty(), removing unnecessary toString() calls, and modernizing string concatenation using String.format().
Key changes:
- Replaced
"".equals(path)withpath.isEmpty()for better readability in Cookie and Platform classes - Removed redundant
toString()call onJSON_UTF_8constant in AbstractHttpCommandCodec - Modernized error message concatenation in ModuleGenerator using
String.format()with explicit UTF-8 charset handling
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| ModuleGenerator.java | Refactored error message concatenation to use String.format() and added StandardCharsets import for explicit UTF-8 encoding |
| Cookie.java | Replaced "".equals(path) with path.isEmpty() in toString() method |
| Platform.java | Replaced "".equals(matcher) with matcher.isEmpty() in OS name matching logic |
| AbstractHttpCommandCodec.java | Removed unnecessary toString() call on JSON_UTF_8 String constant |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… AbstractHttpCommandCodec
114f738 to
c24b3c2
Compare
User description
Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.
This pull request includes several changes to improve code readability and consistency in the Selenium project. The most important changes involve replacing deprecated string methods and updating header content type handling.
Improvements to code readability and consistency:
java/src/dev/selenium/tools/modules/ModuleGenerator.java: Simplified the error message concatenation by removing unnecessarynew Stringconversion.java/src/org/openqa/selenium/Cookie.java: Replaced("".equals(path))withpath.isEmpty()for better readability.java/src/org/openqa/selenium/Platform.java: Replaced("".equals(matcher))withmatcher.isEmpty()for better readability.java/src/org/openqa/selenium/remote/codec/AbstractHttpCommandCodec.java: Removed unnecessarytoString()call onJSON_UTF_8when setting the content type header.Motivation and Context
Types of changes
Checklist
PR Type
Enhancement
Description
Simplified string operations for better readability.
Replaced deprecated or redundant string methods.
Improved header content type handling in HTTP requests.
Enhanced error message concatenation in module processing.
Changes walkthrough 📝
ModuleGenerator.java
Simplified error message concatenation logicjava/src/dev/selenium/tools/modules/ModuleGenerator.java
new Stringconversion.Cookie.java
Improved readability in cookie string representationjava/src/org/openqa/selenium/Cookie.java
("".equals(path))withpath.isEmpty().Platform.java
Improved OS name matching readabilityjava/src/org/openqa/selenium/Platform.java
("".equals(matcher))withmatcher.isEmpty().AbstractHttpCommandCodec.java
Simplified header content type handlingjava/src/org/openqa/selenium/remote/codec/AbstractHttpCommandCodec.java
toString()call onJSON_UTF_8.