| Summary: | [Xtend] support for @SuppressWarnings | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Tools] Xtend | Reporter: | Sven Efftinge <sven.efftinge> | ||||
| Component: | Core | Assignee: | Project Inbox <xtend-inbox> | ||||
| Status: | NEW --- | QA Contact: | |||||
| Severity: | enhancement | ||||||
| Priority: | P3 | CC: | alexander.fichtinger, brsanthu, btickets, daniel.darvas, edward.staub, Holger.Schill, lorenzo.bettini, mirko, miro.spoenemann, moritz.eysholdt, sbouchet, shashwat.work | ||||
| Version: | 2.2.0 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Mac OS X - Carbon (unsup.) | ||||||
| Whiteboard: | |||||||
| Bug Depends on: | |||||||
| Bug Blocks: | 365712 | ||||||
| Attachments: |
|
||||||
|
Description
Sven Efftinge
*** Bug 387974 has been marked as a duplicate of this bug. *** We now have a compiler flag for enabling/disabling the synthetic @SupressWarnings("all").
We should respect @SupressWarnings in the validator, this could be integrated in a specialized IssueSeverities.
If synthetic suppress warnings is activated and a type declaration contains a manual @SupressWarnings, the manual one should not be generated.
Created attachment 225878 [details]
Suggestion to fix this ticket
Pushed fix to avoid manual @SuppressWarnings when synthetic @SuppressWarnings is enabled to master. unscheduling. I thought it was necessary to suppress unused warnings when using Java-black-box expressions in active annotations. But we decided to go with a different protocol. I have the following scenario:
Active Annotation which generates 3 methods.
In an implementation class I declare just the field.
Example:
class ServiceAccessor {
@Service ProjectIndexService projectIndexService
}
This implementation causes an "unused" warning.
It is VERY ANNOYING because there is no way to suppress it (even the xtend-maven-plugin does not have an option to deactivate this warning).
(In reply to Alexander Fichtinger from comment #6) > I have the following scenario: > > Active Annotation which generates 3 methods. > > In an implementation class I declare just the field. > > Example: > > class ServiceAccessor { > @Service ProjectIndexService projectIndexService > } > > This implementation causes an "unused" warning. > > It is VERY ANNOYING because there is no way to suppress it (even the > xtend-maven-plugin does not have an option to deactivate this warning). This is covered in bugzilla #404167 +1 One hack (of many) to work around this, is to do a double assignment:
static MyPackage myPackage = myPackage = MyPackage.eINSTANCE
This obviously doesn't work with finals.
Incidentally, the Ecore idiom above is the use-case that drove me to vote for this enhancement; eINSTANCE registers the package in the global package registry, which is sometimes needed early in static initialization.
(In reply to Alexander Fichtinger from comment #6) > I have the following scenario: > > Active Annotation which generates 3 methods. > > In an implementation class I declare just the field. > > Example: > > class ServiceAccessor { > @Service ProjectIndexService projectIndexService > } > > This implementation causes an "unused" warning. > > It is VERY ANNOYING because there is no way to suppress it (even the > xtend-maven-plugin does not have an option to deactivate this warning). This bit is solved in 2.6 already. There's new API for active annotations that let's you flag a MutableField (markAsRead). Just some additional information:
I don't mind @SuppressWarnings("all"), but
it looks like that this annotation will prevent Sonarqube from reporting
possible issues on the generated Java code (see
http://sonarqube.15.x6.nabble.com/sonarqube-findbugs-and-generated-sources-td5028237.html).
I tried adding an explicit @SuppressWarnings annotation, e.g., @SuppressWarnings("serial"), but the generated Java file still contains @SuppressWarnings("all")
hi,
in my case, i'm using checkstyle on my projects and the @SuppressWarnings("all") on top of every generated class reports no violations. ( of course :) )
I have to manually supress the annotation to have an analysis of the code.
I meanly use it for copyright header checks.
Committed a change for release 2.8: @SuppressWarnings is not generated if it is already present in the Xtend source. This should help for the use cases mentioned above. See also https://bugs.eclipse.org/bugs/show_bug.cgi?id=388749 What is left to be done for this bug: (In reply to Sven Efftinge from comment #2) > We should respect @SupressWarnings in the validator, this could be > integrated in a specialized IssueSeverities. |