{"action":"created","issue":{"url":"https://api.github.com/repos/checkstyle/checkstyle/issues/5746","repository_url":"https://api.github.com/repos/checkstyle/checkstyle","labels_url":"https://api.github.com/repos/checkstyle/checkstyle/issues/5746/labels{/name}","comments_url":"https://api.github.com/repos/checkstyle/checkstyle/issues/5746/comments","events_url":"https://api.github.com/repos/checkstyle/checkstyle/issues/5746/events","html_url":"https://github.com/checkstyle/checkstyle/issues/5746","id":316309549,"number":5746,"title":"UnnecessaryParenthesesCheck: violation changes for anonymous class being assigned to field","user":{"login":"rnveach","id":5427943,"avatar_url":"https://avatars1.githubusercontent.com/u/5427943?v=4","gravatar_id":"","url":"https://api.github.com/users/rnveach","html_url":"https://github.com/rnveach","followers_url":"https://api.github.com/users/rnveach/followers","following_url":"https://api.github.com/users/rnveach/following{/other_user}","gists_url":"https://api.github.com/users/rnveach/gists{/gist_id}","starred_url":"https://api.github.com/users/rnveach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rnveach/subscriptions","organizations_url":"https://api.github.com/users/rnveach/orgs","repos_url":"https://api.github.com/users/rnveach/repos","events_url":"https://api.github.com/users/rnveach/events{/privacy}","received_events_url":"https://api.github.com/users/rnveach/received_events","type":"User","site_admin":false},"labels":[{"id":59160289,"url":"https://api.github.com/repos/checkstyle/checkstyle/labels/approved","name":"approved","color":"009800","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-04-20T15:19:54Z","updated_at":"2018-04-20T21:46:03Z","closed_at":null,"author_association":"OWNER","body":"http://checkstyle.sourceforge.net/config_coding.html#UnnecessaryParentheses\r\n\r\n````\r\n$ cat TestClass.java\r\npublic class TestClass {\r\n    void method() {\r\n        Object a = null;\r\n        test((a == null ? a : null));  // violation\r\n    }\r\n\r\n    private static final MyInnerClass test = new MyInnerClass() {\r\n        public void method() {\r\n            Object a = null;\r\n            test((a == null ? a : null));  // violation\r\n        }\r\n    };\r\n\r\n    private static void test(Object a) {\r\n    }\r\n\r\n    private static class MyInnerClass {\r\n        public void method() {\r\n        }\r\n    }\r\n}\r\n\r\n$ cat TestConfig.xml\r\n<?xml version=\"1.0\"?>\r\n<!DOCTYPE module PUBLIC\r\n          \"-//Puppy Crawl//DTD Check Configuration 1.3//EN\"\r\n          \"http://www.puppycrawl.com/dtds/configuration_1_3.dtd\">\r\n\r\n<module name=\"Checker\">\r\n    <property name=\"charset\" value=\"UTF-8\"/>\r\n\r\n    <module name=\"TreeWalker\">\r\n<module name=\"UnnecessaryParentheses\" />\r\n    </module>\r\n</module>\r\n\r\n$ java -jar checkstyle-8.9-all.jar -c TestConfig.xml TestClass.java\r\nStarting audit...\r\n[ERROR] TestClass.java:4:14: Unnecessary parentheses around expression. [UnnecessaryParentheses]\r\n[ERROR] TestClass.java:10:18: Unnecessary parentheses around assignment right-hand side. [UnnecessaryParentheses]\r\nAudit done.\r\nCheckstyle ends with 2 errors.\r\n````\r\n\r\nThe code is exactly the same for the 2 but one violation is about an expression while the other is about the right-handed side of the assignment. Once we enter the anonymous class, it stopped being about the assignment, so the violation message is misleading. It should be the same for lambdas.\r\nBoth violation messages should say `Unnecessary parentheses around expression`."},"comment":{"url":"https://api.github.com/repos/checkstyle/checkstyle/issues/comments/383231137","html_url":"https://github.com/checkstyle/checkstyle/issues/5746#issuecomment-383231137","issue_url":"https://api.github.com/repos/checkstyle/checkstyle/issues/5746","id":383231137,"user":{"login":"rnveach","id":5427943,"avatar_url":"https://avatars1.githubusercontent.com/u/5427943?v=4","gravatar_id":"","url":"https://api.github.com/users/rnveach","html_url":"https://github.com/rnveach","followers_url":"https://api.github.com/users/rnveach/followers","following_url":"https://api.github.com/users/rnveach/following{/other_user}","gists_url":"https://api.github.com/users/rnveach/gists{/gist_id}","starred_url":"https://api.github.com/users/rnveach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rnveach/subscriptions","organizations_url":"https://api.github.com/users/rnveach/orgs","repos_url":"https://api.github.com/users/rnveach/repos","events_url":"https://api.github.com/users/rnveach/events{/privacy}","received_events_url":"https://api.github.com/users/rnveach/received_events","type":"User","site_admin":false},"created_at":"2018-04-20T21:46:03Z","updated_at":"2018-04-20T21:46:03Z","author_association":"OWNER","body":"> > should Unnecessary parentheses around assignment right-hand side really be shown if it is not around the entire assignment?\r\n\r\n> yes.\r\n\r\nSo your saying the violation message in the 2nd post is correct?\r\nCan you explain why this is when it is not directly related to the assignment?"}}
{"actor":{"display_login":"rnveach"}}