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

Add integration test that searches for unnecessary SuppressWarning annotations in generated code #26629

Closed
spotlesscoder opened this issue Jul 5, 2024 · 1 comment · Fixed by #26630
Milestone

Comments

@spotlesscoder
Copy link
Contributor

Overview of the feature request

Generated a new project with JHipster 8.6.0
The AccountResource.java has an unnecessary SuppressWarning here:

/**
     * {@code GET  /account} : get the current user.
     *
     * @param principal the current user; resolves to {@code null} if not authenticated.
     * @return the current user.
     * @throws AccountResourceException {@code 500 (Internal Server Error)} if the user couldn't be returned.
     */
    @GetMapping("/account")
    @SuppressWarnings("unchecked")
    public AdminUserDTO getAccount(Principal principal) {
        if (principal instanceof AbstractAuthenticationToken) {
            return userService.getUserFromAuthentication((AbstractAuthenticationToken) principal);
        } else {
            throw new AccountResourceException("User could not be found");
        }
    }
Motivation for or Use Case

Code should always be minimal

@spotlesscoder
Copy link
Contributor Author

This fixes this one occurrence of the error.
The be safe that it does not occur again, the generator should have tests that every method is checked - at least check that the suppresswarning is not added when the method does not even have a "throws" declaration at all

@mraible mraible added this to the 8.7.0 milestone Aug 27, 2024
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.

3 participants