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

Issue #13086: InnerAssignmentCheck failed for one line code in Java 1… #14150

Closed
wants to merge 1 commit into from

Conversation

aayushRedHat
Copy link
Contributor

@aayushRedHat
Copy link
Contributor Author

Github, generate report

@nrmancuso
Copy link
Member

Let's get hanging PRs across the finish line before we begin review here: https://github.com/checkstyle/checkstyle/pulls/aayushRedhat

@aayushRedHat
Copy link
Contributor Author

Let's get hanging PRs across the finish line before we begin review here: https://github.com/checkstyle/checkstyle/pulls/aayushRedhat

Please review @nrmancuso @romani

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok to merge, report is good

Copy link
Member

@rnveach rnveach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, I thought this was a swap, but I see it is an addition.

As a note, no test case was ever added for #377 .

@rnveach rnveach assigned nrmancuso and unassigned rnveach Dec 24, 2023
Copy link
Member

@nrmancuso nrmancuso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Item:

package com.puppycrawl.tools.checkstyle.checks.coding.innerassignment;

//non-compiled with javac: Compilable with Java14
public class InputInnerAssignmentWithEnhancedSwitch {
Copy link
Member

@nrmancuso nrmancuso Dec 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add more test cases:

    boolean flag;

    void m1(final String operation) {
        boolean innerFlag;
        innerFlag = switch (operation) {
            case "Y" -> flag = true; // expected violation
            case "N" -> {
                yield flag = false; // expected violation
            }
            default -> throw new UnsupportedOperationException();
        };
    }

    void m2(final String operation) {
        boolean innerFlag;
        switch (operation) {
            case "Y": flag = true; break; // should be ok
            case "N": {
                flag = false; // should be ok
                break;
            }
            default: throw new UnsupportedOperationException();
        }
    }

    void m3(final String operation) {
        boolean innerFlag;
        switch (operation) {
            case "Y" -> flag = innerFlag = true; // expected violation
            case "N" -> {
                flag = innerFlag = false; // expected violation
            }
            default -> throw new UnsupportedOperationException();
        }
    }

@nrmancuso
Copy link
Member

@aayushRedHat ping

@aayushRedHat
Copy link
Contributor Author

@aayushRedHat ping

Sorry @nrmancuso @romani for the delay in my PR. I was on Holidays, will start working tomorrow.

@nrmancuso nrmancuso removed their assignment Feb 6, 2024
@nrmancuso
Copy link
Member

We lost contact with PR author, anyone is welcome to pick this up and reuse the code here

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.

None yet

4 participants