Skip to content

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

Closed
@akarnokd

Description

@akarnokd

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions