swagger-api / swagger-api/swagger-codegen
Suggestion: use final in method parameters
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I always make all operation parameters final, I consider it a 'best practice'. It is also recommended in the default checkstyle configuration.
As a justification for it, I came across code like this a couple of years ago:
class X {
...
private B b;
...
someOperation(B b) {
// some code
B x = some transformation that depends on b.
// some code.
b = x; // The intention was this.b = x;
}
...
}
I spent more than 1/2 an hour tracking the bug, so now I am as strong supporter of final in method parameters.
Suggest a Fix
I suggest to include final in method parameters as a coding convention rule in swagger.
I also like adding checkstyle as part of the build, so it is very easy to fix some convention violations.
All thoughts appreciated.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the repository's default Checkstyle configuration and the Java generation templates or build entry points. Determine whether the convention applies to generated Java method parameters and how Checkstyle is integrated; done means the agreed rule is enabled and the affected build or validation path passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100