- Stack Overflow Public questions & answers
- Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
- Talent Build your employer brand
- Advertising Reach developers & technologists worldwide
- About the company

Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Sonar violation on "disallowed assignment of parameters"
I have the following code and I got an sonar violation error: disallowed assignment of parameters What is the best way to fix this?

I suspect one of 2 things are happening here:
1 - There is a bug in the checkstyle plugin
2 - The code sonar analysed is not quite the code you posted here
I believe that violation should apply in the following case:
So when you are reassigning the method parameter it would be expected, but in your example you are not, you are assigning it to a class field so it should be ok.
Try changing the method parameter to final and see if you still see the violation.

Your Answer
Sign up or log in, post as a guest.
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct .
Not the answer you're looking for? Browse other questions tagged java sonarqube or ask your own question .
- The Overflow Blog
- For those who just don’t Git it (Ep. 573)
- How to use marketing techniques to build a better resume
- Featured on Meta
- AI/ML Tool examples part 3 - Title-Drafting Assistant
- We are graduating the updated button styling for vote arrows
- Temporary policy: ChatGPT is banned
- The [connect] tag is being burninated
- Stack Overflow will be testing a title-drafting assistant, and we’d like your...
- We are graduating the "Related questions using Machine Learning" experiment
Hot Network Questions
- Ortho- Para- Hydrogen Names and Benzene
- Finding roots of complicated expression involving DawsonF
- Python code using *args to print warnings in color
- What is this probe on the Airbus A330 engine nacelle?
- Why are there two inverses to exponentiation?
- Sql server replication - reinitialize from an ID onwards?
- The secret to well-seasoned pulled pork
- How do we know the expansion of the universe is not centered around our position?
- Existing NEMA 10-30R for dryer wired with hot hot ground instead of neutral?
- How can someone be of two nationalities during the First World War?
- Is an AI model considered a derivative work?
- What does the "proportional symbol" (∝) mean when used as a time unit prefix?
- I will grab a taxi back. vs. I will grab back a taxi
- In 18th century England, was "eat" the past tense of "eat" and how was it pronounced?
- Can you use the Seeming spell to appear invisible?
- Store Firefox Primary Password in Secret Service
- is iii7 a dominant chord with scale degree 3?
- Challenges of publishing a single-author paper in computer science
- Re-checking baggage for international to domestic transit at San Francisco? (long layover)
- Do Errant and Giada and Rattlechains allow me to cast Spirits with flying from my library at instant speed?
- Probability of a given result with multiples of mixed dice with different number of faces
- Six of one maybe?
- Is the "stupid" in "Keep it simple, stupid" a form of address or a second adjective that you should "keep it"?
- How serious is it that my new teammates didn't show up to a meeting I set up that they agreed to attend?
Your privacy
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .

Remove Assignments to Parameters
Some value is assigned to a parameter inside method’s body.
Use a local variable instead of a parameter.
Why Refactor
The reasons for this refactoring are the same as for Split Temporary Variable , but in this case we’re dealing with a parameter, not a local variable.
First, if a parameter is passed via reference, then after the parameter value is changed inside the method, this value is passed to the argument that requested calling this method. Very often, this occurs accidentally and leads to unfortunate effects. Even if parameters are usually passed by value (and not by reference) in your programming language, this coding quirk may alienate those who are unaccustomed to it.
Second, multiple assignments of different values to a single parameter make it difficult for you to know what data should be contained in the parameter at any particular point in time. The problem worsens if your parameter and its contents are documented but the actual value is capable of differing from what’s expected inside the method.
Each element of the program should be responsible for only one thing. This makes code maintenance much easier going forward, since you can safely replace code without any side effects.
This refactoring helps to extract repetitive code to separate methods .
How to Refactor
Create a local variable and assign the initial value of your parameter.
In all method code that follows this line, replace the parameter with your new local variable.
Tired of reading?
No wonder, it takes 7 hours to read all of the text we have here.
Try our interactive course on refactoring. It offers a less tedious approach to learning new stuff.
Skip to Content
Skip over Site Identifier
- Region and language Service & Support
- Deutsch Deutsch
Service & Support
Skip over Generic Navigation
- Contact Contact
- Support Request Support Request
Skip over Search
Skip over Site Explorer
Site Explorer Site Explorer
- Product Support

Parameter assignment error
Created by: royalmaster at: 5/18/2018 10:04 am (10 replies), rating (1) thanks 1, entries per page: 10 | all, all about step 7 (tia portal), presales info, catalog and ordering system online, technical info, contact & partners, follow us on.

IMAGES
VIDEO
COMMENTS
In my Sonar I have an error that says: 'Assignment of Parameter 'variable' is not allowed. The line that it's on is: @RequestParam (value="variable", required=false) String variable. So I'm wondering how I could get that error off since I can't just create a setter when I'm using that annotation.
I suspect one of 2 things are happening here: 1 - There is a bug in the checkstyle plugin. 2 - The code sonar analysed is not quite the code you posted here. I believe that violation should apply in the following case: /** * @param lastAccessTime the lastAccessTime to set */ public void setLastAccessTime (Date lastAccessTime) { lastAccessTime ...
Disallows assignment of parameters. Rationale: Parameter assignment is often considered poor programming practice. Forcing developers to declare parameters as final is often onerous. Having a check ensure that parameters are never assigned would give the best of both worlds.
hi, yes, this could be the problem. when the addresses of a F-IO is not used in the F-programm, the DB of the F-module is not loaded with HW-configuration and this can cause an error. Try to use one of the F- inputs/output in the F-programm, to verify if I am right.