@SuppressWarnings('LineLength') is broken for enums
Here is a class that creates a violation that shouldn't.
package com.bestence.rom.importdto.mapping.libra
import com.bestence.rom.importdto.mapping.Mapping
@SuppressWarnings('LineLength')
enum LibraAuftragseingangMapping {
static mappings = MappedProperty.values().inject([:]) { map, mappedProperty ->
map << [(mappedProperty.columnIndex): [propertyName: mappedProperty.propertyName, headerName: mappedProperty.headerName]]
}
static enum MappedProperty implements Mapping {
LAUFNUMMER (0 , 'laufnummer' , 'lfd. Nr.' ) ,
VFIAN (1 , 'vfIan' , 'VF-IAN' ) ,
FVBK_MP1_ANFRAGE (24, 'fVbKMP1Anfrage' , 'FVbK MP 1 Anfrage '),
FVBK_MP3A_AUFTRAGANEXTDLVERSCHICKT (25, 'fVbKMP3aAuftraganextDLverschickt' , 'FVbK MP 3a Auftrag an ext. DL verschickt '),
FVBK_MP6_BSAEXTDL (26, 'fVbKMP6BSAextDL' , 'FVbK MP 6 BSA ext. DL'),
NETZERWEITERUNG_MP1AGRUNDDOKUMENTATIONBEAUFTRAGEN (27, 'netzerweiterungMP1aGrundDokumentationbeauftragen' , 'Netzerweiterung MP 1a Grund-dokumentation beauftragen'),
NETZERWEITERUNG_MP1BGRUNDDOKUMENTATIONERSTELLT (28, 'netzerweiterungMP1bGrundDokumentationerstellt' , 'Netzerweiterung MP 1b Grund-dokumentation erstellt'),
NETZERWEITERUNG_ACCESS_HVT_MP1_PLANUNGSAUFTRAG (29, 'netzerweiterungAccessHVTMP1Planungsauftrag' , 'Netzerweiterung Access HVTMP 1 Planungsauftrag'),
NETZERWEITERUNG_ACCESS_HVT_MP2_DEPLOYMENTAUFTRAGHUAWEISPEC (30, 'netzerweiterungAccessHVTMP2DeploymentAuftragHuaweiSpec' , 'Netzerweiterung Access HVT MP 2 Deployment Auftrag/ Huawei Spec'),
NETZERWEITERUNG_ACCESS_HVT_MP3_POHUAWEI (31, 'netzerweiterungAccessHVTMP3POHuawei' , 'Netzerweiterung Access HVT MP 3 PO Huawei'),
NETZERWEITERUNG_BACKBONE_MP12_RFSDF (72, 'netzerweiterungBackboneMP12RFSDF' , 'Netzerweiterung Backbone MP 12 RFS DF'),
NETZERWEITERUNG_BACKBONE_MP13_ANGEBOTHUAWEI (73, 'netzerweiterungBackboneMP13AngebotHuawei' , 'Netzerweiterung Backbone MP 13 Angebot Huawei'),
int columnIndex
String propertyName
String headerName
MappedProperty(int columnIndex, String propertyName, String headerName) {
this.columnIndex = columnIndex
this.propertyName = propertyName
this.headerName = headerName
}
}
}
The problem here seems to be that the @SuppressWarnings support, implemented in the SuppressionAnalyzer class, is based on checking for annotations on ASTNodes -- class, field, method, etc..
But this rule is one of the few that is based on iterating through the source code rather than processing/visiting ASTNodes, so those annotations on AST nodes are ignored.
One option that occurs to me is to redesign this rule so that it processes the source code for each class individually, checking the source lines between the class start and end. It would use the typical visitClassNode() behavior, getting the suppression processing along with that. One downside of that is that it would work only for class-level annotations, so if the user puts a @SuppressWarnings annotation on the method, it would be ignored -- partial solution and partial confusion :)
For now, I will update the rule doc, noting this current limitation.