{"action":"created","issue":{"url":"https://api.github.com/repos/checkstyle/checkstyle/issues/3146","repository_url":"https://api.github.com/repos/checkstyle/checkstyle","labels_url":"https://api.github.com/repos/checkstyle/checkstyle/issues/3146/labels{/name}","comments_url":"https://api.github.com/repos/checkstyle/checkstyle/issues/3146/comments","events_url":"https://api.github.com/repos/checkstyle/checkstyle/issues/3146/events","html_url":"https://github.com/checkstyle/checkstyle/pull/3146","id":151863152,"number":3146,"title":"Issue #3144: fixed NPE in FinalLocalVariable for lambda in field","user":{"login":"rnveach","id":5427943,"avatar_url":"https://avatars.githubusercontent.com/u/5427943?v=3","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":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-04-29T13:16:39Z","updated_at":"2016-05-01T03:45:10Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/checkstyle/checkstyle/pulls/3146","html_url":"https://github.com/checkstyle/checkstyle/pull/3146","diff_url":"https://github.com/checkstyle/checkstyle/pull/3146.diff","patch_url":"https://github.com/checkstyle/checkstyle/pull/3146.patch"},"body":"Issue #3144 \r\n\r\nException is because we are in an interface and `findFirstUpperNamedBlock` wasn't stopping at the interface definition.\r\nCode fix has it now stopping at the field definition. This is because the code was original stopping at methods, and fields are on the same hierarchy, so I thought it was better to stop here."},"comment":{"url":"https://api.github.com/repos/checkstyle/checkstyle/issues/comments/216012888","html_url":"https://github.com/checkstyle/checkstyle/pull/3146#issuecomment-216012888","issue_url":"https://api.github.com/repos/checkstyle/checkstyle/issues/3146","id":216012888,"user":{"login":"rnveach","id":5427943,"avatar_url":"https://avatars.githubusercontent.com/u/5427943?v=3","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":"2016-05-01T03:45:10Z","updated_at":"2016-05-01T03:45:10Z","body":"> Why \"||\" is required ? \r\n\r\n`astTraverse.getType() != TokenTypes.VARIABLE_DEF` was required so we stop on fields, which are defined on `VARIABLE_DEF`. `!ScopeUtils.isClassFieldDef` was so it wasn't stopping on local variables, like in a method.\r\nThese 2 lines together were saying \"stop on variable def that is defined in the class level\" (A && B), which are fields. Statements however in this loop are written as a negative. The negative of `A && B` is `!A || !B`. Hence my final code.\r\nEven though `isLocalVariableDef` already checks `VARIABLE_DEF` it also includes `PARAMETER_DEF`. If I remove the `VARIABLE_DEF` check I get false positives like:\r\nhttps://github.com/checkstyle/checkstyle/blob/ccdc3c09c500ccd31d56e4d6ed9c2d86edf2e9f1/src/test/resources/com/puppycrawl/tools/checkstyle/checks/coding/InputFinalLocalVariable.java#L45\r\nInputFinalLocalVariable.java:45:56: Variable 'aArg2' should be declared final.\r\n\r\nIn the end, I think I was right using `isClassFieldDef` by name alone. If it included the check of `VARIABLE_DEF`, which is required for a class field, then I could remove the `||`. The method is only used in `DeclarationOrderCheck` in a `VARIABLE_DEF` case, so this could be why nothing else is seeing an issue.\r\nAre you ok with me modifying the method instead of changing to `isLocalVariableDef`?"}}