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

[EC27] System.arraycopy cannot always be used #19

Open
fmunch opened this issue Feb 13, 2024 · 2 comments
Open

[EC27] System.arraycopy cannot always be used #19

fmunch opened this issue Feb 13, 2024 · 2 comments
Labels
🗃️ rule rule improvment or rule development or bug

Comments

@fmunch
Copy link

fmunch commented Feb 13, 2024

Describe the bug
EC27 suggests System.arraycopy when it is not applicable.

Expected behavior
System.arraycopy should not be suggested when the code inside the loop filters / modifies / ... the values.

Screenshots
ec27

Software Versions

  • SonarQube Version: 10.3
  • Plugin Version: 1.4.3
@dedece35
Copy link
Member

Hi @fmunch,

in this use case, I agree with you but we can't delete this rule or change the behaviour for a few special uses cases that don't often occur.
For me, your use case is a real use of array copy with deletion of whitspaces, but it is special uses case.
Generally, our rule implementations don't cover all uses cases and some special use cases can't be implemented.

I think you have to mark this use case as not applicable for the rule with a "// NOSONAR" comment with the explanation at the end of the line where the error occurs.

Did you check if it already exists other "System.arrayCopy" method with different parameters to exclude some elements in the copy ?

@dedece35 dedece35 added the 🗃️ rule rule improvment or rule development or bug label Feb 16, 2024
@fmunch
Copy link
Author

fmunch commented Feb 16, 2024

This is the only method in System to copy arrays. I'm guessing that the point of it is to copy quickly some memory section, I doubt more evolved versions would make sense.

I will just mark the code smell as false positive.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🗃️ rule rule improvment or rule development or bug
Projects
None yet
Development

No branches or pull requests

2 participants