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

3.x: Validate argument naming consistency between base class methods #6832

Closed
akarnokd opened this issue Jan 10, 2020 · 0 comments · Fixed by #6853
Closed

3.x: Validate argument naming consistency between base class methods #6832

akarnokd opened this issue Jan 10, 2020 · 0 comments · Fixed by #6853
Milestone

Comments

@akarnokd
Copy link
Member

akarnokd commented Jan 10, 2020

Operator argument naming should match between base classes on the same operators.

For example Observable::buffer(boundary) vs. Flowable::buffer(boundaryIndicator).

Source-level comparison would be too complicated so reflection can be used for this, provided the class saves the argument names. Javac 8 has this option that must be enabled in the IDE and in build.gradle:

[compileJava, compileTestJava]*.options*.compilerArgs << "-parameters"

tasks.withType(JavaCompile) {
    options.compilerArgs << "-parameters";
}

An extra test is preferrable to remind users enabling this option:

    void method(int paramName) {
        // deliberately empty
    }

    @Test
    public void javacParametersEnabled() throws Exception {
        assertEquals("Please enable saving parameter names via the -parameters javac argument",
                "paramName",
                getClass()
                .getDeclaredMethod("method", Integer.TYPE)
                .getParameters()[0].getName());
    }

There are some common operator names across all base classes, these should match as well.

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

Successfully merging a pull request may close this issue.

1 participant