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

[java] rawtypes javac warning fix for AbstractDriverOptions #15048

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

iampopovich
Copy link
Contributor

@iampopovich iampopovich commented Jan 8, 2025

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.

Description

This pull request includes a modification to the AbstractDriverOptions class in the Selenium project to improve type safety and ensure proper type inference for subclasses.

Type safety improvement:

Motivation and Context

i just found easy to fix javac warning with command
javac -Xlint:rawtypes -d out -sourcepath src src/org/openqa/selenium/remote/AbstractDriverOptions.java
and got output

src/org/openqa/selenium/remote/AbstractDriverOptions.java:43: warning: [rawtypes] found raw type: AbstractDriverOptions
public abstract class AbstractDriverOptions<DO extends AbstractDriverOptions>
                                                       ^
  missing type arguments for generic class AbstractDriverOptions<DO>
  where DO is a type-variable:
    DO extends AbstractDriverOptions declared in class AbstractDriverOptions
Note: src/org/openqa/selenium/net/HostIdentifier.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: src/org/openqa/selenium/remote/AbstractDriverOptions.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 warning

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

PR Type

Bug fix, Enhancement


Description

  • Fixed raw type usage in AbstractDriverOptions to suppress javac warnings.

  • Enhanced type safety by refining generic type parameter.

  • Improved type inference for subclasses of AbstractDriverOptions.


Changes walkthrough 📝

Relevant files
Enhancement
AbstractDriverOptions.java
Refined generic type parameter for type safety                     

java/src/org/openqa/selenium/remote/AbstractDriverOptions.java

  • Updated generic type parameter to extend AbstractDriverOptions.
  • Resolved javac raw type warning for AbstractDriverOptions.
  • Improved type inference for subclasses.
  • +1/-1     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link
    Contributor

    qodo-merge-pro bot commented Jan 8, 2025

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ No major issues detected

    Copy link
    Contributor

    qodo-merge-pro bot commented Jan 8, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    General
    Add appropriate annotation to suppress unchecked type casting warning while maintaining type safety

    Add @SuppressWarnings("unchecked") annotation to the setBrowserVersion method since
    it performs an unchecked cast to DO. This will explicitly acknowledge and suppress
    the compiler warning about type safety.

    java/src/org/openqa/selenium/remote/AbstractDriverOptions.java [45-47]

    +@SuppressWarnings("unchecked")
     public DO setBrowserVersion(String browserVersion) {
       setCapability(BROWSER_VERSION, Require.nonNull("Browser version", browserVersion));
       return (DO) this;
    • Apply this suggestion
    Suggestion importance[1-10]: 5

    Why: The suggestion addresses a valid compiler warning by adding @SuppressWarnings("unchecked"), which is a good practice for documenting intentional type-casting. However, this is a relatively minor improvement that doesn't affect functionality.

    5

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant