Skip to content

Commit c02671f

Browse files
Bananeweizenlkoe
authored andcommitted
enable automatic save actions in Eclipse
This change enables automatic save actions on eclipse-cs core and ui. I noticed that some recent changes had introduced unused imports and was surprised to discover they are not automatically removed in eclipse-cs. Both the core and ui project now have the same automated cleanup on save. It has been applied to the complete sources already, so later commits will not have unwanted cleanups mixed their functional change. There are no functional changes in this commit. The configuration for the cleanup is rather conservative. E.g. it disables * organize imports (since the import order seems not to be the default import order in many files) * remove trailing whitespace (many of the Javadocs contain trailing whitespace) * remove unnecessary casts (this one is especially important because our compilation target platform is different than our development target platform)
1 parent 1f06187 commit c02671f

40 files changed

+199
-85
lines changed

net.sf.eclipsecs.core/.settings/org.eclipse.jdt.ui.prefs

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,23 @@ cleanup.make_local_variable_final=true
2121
cleanup.make_parameters_final=true
2222
cleanup.make_private_fields_final=true
2323
cleanup.make_type_abstract_if_missing_method=false
24-
cleanup.make_variable_declarations_final=true
24+
cleanup.make_variable_declarations_final=false
2525
cleanup.never_use_blocks=false
2626
cleanup.never_use_parentheses_in_expressions=true
27-
cleanup.organize_imports=true
27+
cleanup.organize_imports=false
2828
cleanup.qualify_static_field_accesses_with_declaring_class=false
2929
cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
3030
cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
3131
cleanup.qualify_static_member_accesses_with_declaring_class=true
3232
cleanup.qualify_static_method_accesses_with_declaring_class=false
3333
cleanup.remove_private_constructors=true
34+
cleanup.remove_redundant_modifiers=false
35+
cleanup.remove_redundant_semicolons=true
3436
cleanup.remove_redundant_type_arguments=true
3537
cleanup.remove_trailing_whitespaces=false
3638
cleanup.remove_trailing_whitespaces_all=true
3739
cleanup.remove_trailing_whitespaces_ignore_empty=false
38-
cleanup.remove_unnecessary_casts=true
40+
cleanup.remove_unnecessary_casts=false
3941
cleanup.remove_unnecessary_nls_tags=true
4042
cleanup.remove_unused_imports=true
4143
cleanup.remove_unused_local_variables=false
@@ -54,9 +56,68 @@ cleanup.use_this_for_non_static_field_access=false
5456
cleanup.use_this_for_non_static_field_access_only_if_necessary=true
5557
cleanup.use_this_for_non_static_method_access=false
5658
cleanup.use_this_for_non_static_method_access_only_if_necessary=true
57-
cleanup.use_type_arguments=false
58-
cleanup_profile=_eclipse-cs net.sf.eclipsecs.core
59+
cleanup_profile=_eclipse-cs
5960
cleanup_settings_version=2
6061
eclipse.preferences.version=1
62+
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
6163
formatter_profile=_Checkstyle
6264
formatter_settings_version=13
65+
sp_cleanup.add_default_serial_version_id=true
66+
sp_cleanup.add_generated_serial_version_id=false
67+
sp_cleanup.add_missing_annotations=true
68+
sp_cleanup.add_missing_deprecated_annotations=true
69+
sp_cleanup.add_missing_methods=false
70+
sp_cleanup.add_missing_nls_tags=false
71+
sp_cleanup.add_missing_override_annotations=true
72+
sp_cleanup.add_missing_override_annotations_interface_methods=true
73+
sp_cleanup.add_serial_version_id=false
74+
sp_cleanup.always_use_blocks=true
75+
sp_cleanup.always_use_parentheses_in_expressions=false
76+
sp_cleanup.always_use_this_for_non_static_field_access=false
77+
sp_cleanup.always_use_this_for_non_static_method_access=false
78+
sp_cleanup.convert_functional_interfaces=false
79+
sp_cleanup.convert_to_enhanced_for_loop=false
80+
sp_cleanup.correct_indentation=false
81+
sp_cleanup.format_source_code=false
82+
sp_cleanup.format_source_code_changes_only=false
83+
sp_cleanup.insert_inferred_type_arguments=false
84+
sp_cleanup.make_local_variable_final=true
85+
sp_cleanup.make_parameters_final=false
86+
sp_cleanup.make_private_fields_final=true
87+
sp_cleanup.make_type_abstract_if_missing_method=false
88+
sp_cleanup.make_variable_declarations_final=false
89+
sp_cleanup.never_use_blocks=false
90+
sp_cleanup.never_use_parentheses_in_expressions=true
91+
sp_cleanup.on_save_use_additional_actions=true
92+
sp_cleanup.organize_imports=false
93+
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
94+
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
95+
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
96+
sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
97+
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
98+
sp_cleanup.remove_private_constructors=true
99+
sp_cleanup.remove_redundant_modifiers=false
100+
sp_cleanup.remove_redundant_semicolons=true
101+
sp_cleanup.remove_redundant_type_arguments=true
102+
sp_cleanup.remove_trailing_whitespaces=true
103+
sp_cleanup.remove_trailing_whitespaces_all=true
104+
sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
105+
sp_cleanup.remove_unnecessary_casts=true
106+
sp_cleanup.remove_unnecessary_nls_tags=true
107+
sp_cleanup.remove_unused_imports=true
108+
sp_cleanup.remove_unused_local_variables=false
109+
sp_cleanup.remove_unused_private_fields=true
110+
sp_cleanup.remove_unused_private_members=false
111+
sp_cleanup.remove_unused_private_methods=true
112+
sp_cleanup.remove_unused_private_types=true
113+
sp_cleanup.sort_members=false
114+
sp_cleanup.sort_members_all=false
115+
sp_cleanup.use_anonymous_class_creation=false
116+
sp_cleanup.use_blocks=false
117+
sp_cleanup.use_blocks_only_for_return_and_throw=false
118+
sp_cleanup.use_lambda=true
119+
sp_cleanup.use_parentheses_in_expressions=false
120+
sp_cleanup.use_this_for_non_static_field_access=false
121+
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
122+
sp_cleanup.use_this_for_non_static_method_access=false
123+
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true

net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/config/CheckConfigurationTester.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private static class MissingPropertyCollector implements PropertyResolver {
123123
"project_loc"); //$NON-NLS-1$
124124

125125
/** The list of unresolved properties. */
126-
private List<ResolvableProperty> mUnresolvedProperties = new ArrayList<ResolvableProperty>();
126+
private List<ResolvableProperty> mUnresolvedProperties = new ArrayList<>();
127127

128128
/**
129129
* {@inheritDoc}

net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/config/CheckConfigurationWorkingCopy.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ public class CheckConfigurationWorkingCopy implements ICheckConfiguration, Clone
7373
private String mEditedDescription;
7474

7575
/** The list of resolvable properties. */
76-
private List<ResolvableProperty> mProperties = new ArrayList<ResolvableProperty>();
76+
private List<ResolvableProperty> mProperties = new ArrayList<>();
7777

7878
/** The map of additional data for this configuration. */
79-
private Map<String, String> mAdditionalData = new HashMap<String, String>();
79+
private Map<String, String> mAdditionalData = new HashMap<>();
8080

8181
/** flags if the configuration is dirty. */
8282
private boolean mHasConfigChanged;
@@ -375,10 +375,10 @@ public CheckConfigurationWorkingCopy clone() {
375375
try {
376376
clone = (CheckConfigurationWorkingCopy) super.clone();
377377

378-
clone.mAdditionalData = new HashMap<String, String>();
378+
clone.mAdditionalData = new HashMap<>();
379379
clone.mAdditionalData.putAll(this.mAdditionalData);
380380

381-
clone.mProperties = new ArrayList<ResolvableProperty>();
381+
clone.mProperties = new ArrayList<>();
382382

383383
for (ResolvableProperty prop : mProperties) {
384384
clone.mProperties.add(prop.clone());

net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/config/GlobalCheckConfigurationWorkingSet.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ public class GlobalCheckConfigurationWorkingSet implements ICheckConfigurationWo
8282
GlobalCheckConfigurationWorkingSet(List<ICheckConfiguration> checkConfigs,
8383
ICheckConfiguration defaultConfig, ICheckConfiguration defaultBuiltInCheckConfiguration) {
8484

85-
mWorkingCopies = new ArrayList<CheckConfigurationWorkingCopy>();
86-
mDeletedConfigurations = new ArrayList<CheckConfigurationWorkingCopy>();
85+
mWorkingCopies = new ArrayList<>();
86+
mDeletedConfigurations = new ArrayList<>();
8787
mDefaultBuiltInCheckConfig = defaultBuiltInCheckConfiguration;
8888

8989
for (ICheckConfiguration cfg : checkConfigs) {
@@ -211,7 +211,7 @@ public boolean isDirty() {
211211
@Override
212212
public Collection<IProject> getAffectedProjects() throws CheckstylePluginException {
213213

214-
Set<IProject> projects = new HashSet<IProject>();
214+
Set<IProject> projects = new HashSet<>();
215215

216216
CheckConfigurationWorkingCopy[] workingCopies = this.getWorkingCopies();
217217
for (int i = 0; i < workingCopies.length; i++) {

net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/config/Module.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class Module implements Cloneable {
4747
private RuleMetadata mMetaData;
4848

4949
/** the properties of the modules. */
50-
private List<ConfigProperty> mProperties = new ArrayList<ConfigProperty>();
50+
private List<ConfigProperty> mProperties = new ArrayList<>();
5151

5252
/** the comment of the module. */
5353
private String mComment;
@@ -56,7 +56,7 @@ public class Module implements Cloneable {
5656
private String mId;
5757

5858
/** the custom messages for this module. */
59-
private final Map<String, String> mCustomMessages = new HashMap<String, String>();
59+
private final Map<String, String> mCustomMessages = new HashMap<>();
6060

6161
/** the severity level. */
6262
private Severity mSeverityLevel = Severity.inherit;
@@ -65,7 +65,7 @@ public class Module implements Cloneable {
6565
private Severity mLastEnabledSeverity;
6666

6767
/** map containing unknown custom metadata of the module. */
68-
private final Map<String, String> mCustomMetaData = new HashMap<String, String>();
68+
private final Map<String, String> mCustomMetaData = new HashMap<>();
6969

7070
//
7171
// constructors
@@ -303,7 +303,7 @@ public Map<String, String> getCustomMetaData() {
303303
public Module clone() {
304304
try {
305305
Module clone = (Module) super.clone();
306-
clone.mProperties = new ArrayList<ConfigProperty>();
306+
clone.mProperties = new ArrayList<>();
307307

308308
for (ConfigProperty prop : mProperties) {
309309
clone.getProperties().add(prop.clone());

net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/config/configtypes/ConfigurationTypes.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public final class ConfigurationTypes {
7171
*/
7272
static {
7373

74-
CONFIGURATION_TYPES = new LinkedHashMap<String, IConfigurationType>();
74+
CONFIGURATION_TYPES = new LinkedHashMap<>();
7575

7676
IExtensionRegistry pluginRegistry = Platform.getExtensionRegistry();
7777

@@ -116,7 +116,7 @@ private ConfigurationTypes() {
116116
* @return the configuration types.
117117
*/
118118
public static IConfigurationType[] getCreatableConfigTypes() {
119-
List<IConfigurationType> creatableTypes = new ArrayList<IConfigurationType>();
119+
List<IConfigurationType> creatableTypes = new ArrayList<>();
120120

121121
for (IConfigurationType type : CONFIGURATION_TYPES.values()) {
122122
if (type.isCreatable()) {
@@ -135,7 +135,7 @@ public static IConfigurationType[] getCreatableConfigTypes() {
135135
*/
136136
public static IConfigurationType[] getConfigurableConfigTypes() {
137137

138-
List<IConfigurationType> configurableTypes = new ArrayList<IConfigurationType>();
138+
List<IConfigurationType> configurableTypes = new ArrayList<>();
139139
configurableTypes.addAll(Arrays.asList(getCreatableConfigTypes()));
140140

141141
IConfigurationType remoteType = getByInternalName("remote"); //$NON-NLS-1$

net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/config/configtypes/MultiPropertyResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
public class MultiPropertyResolver implements PropertyResolver, IContextAware {
4040

4141
/** The list of PropertyResolvers. */
42-
private List<PropertyResolver> mChildResolver = new ArrayList<PropertyResolver>();
42+
private List<PropertyResolver> mChildResolver = new ArrayList<>();
4343

4444
/**
4545
* Adds a PropertyResolver to this aggregation property resolver.

net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/config/meta/AllTokensProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
public class AllTokensProvider implements IOptionProvider {
3636

3737
/** the list of options. */
38-
private static List<String> sAllOptions = new ArrayList<String>();
38+
private static List<String> sAllOptions = new ArrayList<>();
3939

4040
/** Static initializer. Builds the option list. */
4141
static {

net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/config/meta/ConfigPropertyMetadata.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class ConfigPropertyMetadata {
4646
private String mDescription;
4747

4848
/** The list of possible property values. */
49-
private List<String> mEnumeration = new ArrayList<String>();
49+
private List<String> mEnumeration = new ArrayList<>();
5050

5151
/**
5252
* Creates the property metadata.

net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/config/meta/RuleMetadata.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public class RuleMetadata {
5757
private final Severity mDefaultSeverityLevel;
5858

5959
/** The list of property metadata. */
60-
private final List<ConfigPropertyMetadata> mConfigPropMetadata = new LinkedList<ConfigPropertyMetadata>();
60+
private final List<ConfigPropertyMetadata> mConfigPropMetadata = new LinkedList<>();
6161

6262
/** The group. */
6363
private final RuleGroupMetadata mGroup;
@@ -106,9 +106,9 @@ public RuleMetadata(String ruleName, String internalName, String parent, Severit
106106
mHasSeverity = hasSeverity;
107107
mIsDeletable = deletable;
108108
mGroup = group;
109-
mAlternativeNames = new ArrayList<String>();
110-
mQuickfixes = new ArrayList<String>();
111-
mMessageKeys = new ArrayList<String>();
109+
mAlternativeNames = new ArrayList<>();
110+
mQuickfixes = new ArrayList<>();
111+
mMessageKeys = new ArrayList<>();
112112
mIsSingleton = isSingleton;
113113
}
114114

0 commit comments

Comments
 (0)