Skip to content

Commit bbddd78

Browse files
committed
general inspection code cleanup
1 parent 060f3bb commit bbddd78

File tree

219 files changed

+404
-466
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

219 files changed

+404
-466
lines changed

src/main/java/fr/adrienbrault/idea/symfony2plugin/ServiceContainerSettingsLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
public class ServiceContainerSettingsLoader implements ServiceContainerLoader {
1515

16-
private static Condition<ContainerFile> CONDITION = new ContainerFileCondition();
16+
private static final Condition<ContainerFile> CONDITION = new ContainerFileCondition();
1717

1818
@Override
1919
public void attachContainerFile(ServiceContainerLoaderParameter parameter) {

src/main/java/fr/adrienbrault/idea/symfony2plugin/Settings.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ public class Settings implements PersistentStateComponent<Settings> {
3737
"var/cache/dev/UrlGenerator.php" // Symfony >= 4
3838
);
3939

40-
public static String DEFAULT_TRANSLATION_PATH = "var/cache/dev/translations";
40+
public static final String DEFAULT_TRANSLATION_PATH = "var/cache/dev/translations";
4141

42-
public static String DEFAULT_WEB_DIRECTORY = "public";
43-
public static String DEFAULT_APP_DIRECTORY = "app";
42+
public static final String DEFAULT_WEB_DIRECTORY = "public";
43+
public static final String DEFAULT_APP_DIRECTORY = "app";
4444

4545
public String pathToTranslation = DEFAULT_TRANSLATION_PATH;
4646
public String directoryToWeb = DEFAULT_WEB_DIRECTORY;

src/main/java/fr/adrienbrault/idea/symfony2plugin/SettingsForm.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*/
3333
public class SettingsForm implements Configurable {
3434

35-
private Project project;
35+
private final Project project;
3636

3737
private JPanel panel1;
3838

src/main/java/fr/adrienbrault/idea/symfony2plugin/Symfony2ProjectComponent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void dispose() {
4646
}
4747
}
4848

49-
public static String HELP_URL = "https://espend.de/phpstorm/plugin/symfony";
49+
public static final String HELP_URL = "https://espend.de/phpstorm/plugin/symfony";
5050
final private static Logger LOG = Logger.getInstance("Symfony-Plugin");
5151
private static final ExtensionPointName<ServiceContainerLoader> SERVICE_CONTAINER_POINT_NAME = new ExtensionPointName<>("fr.adrienbrault.idea.symfony2plugin.extension.ServiceContainerLoader");
5252
public static final ExtensionPointName<PluginConfigurationExtension> PLUGIN_CONFIGURATION_EXTENSION = new ExtensionPointName<>("fr.adrienbrault.idea.symfony2plugin.extension.PluginConfigurationExtension");
@@ -63,7 +63,7 @@ public static Collection<File> getContainerFiles(@NotNull Project project) {
6363
loaderExtension.attachContainerFile(containerLoaderExtensionParameter);
6464
}
6565

66-
if(containerFiles.size() == 0) {
66+
if(containerFiles.isEmpty()) {
6767
for (String s : ServiceContainerUtil.getContainerFiles(project)) {
6868
containerFiles.add(new ContainerFile(s));
6969
}

src/main/java/fr/adrienbrault/idea/symfony2plugin/action/SymfonySymbolSearchAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public void processElementsWithName(@NotNull String name, @NotNull Processor<? s
217217
}
218218
}
219219

220-
if(controllers.size() > 0) {
220+
if(!controllers.isEmpty()) {
221221
for (String controller : controllers) {
222222
for(PsiElement psiElement: RouteHelper.getMethodsOnControllerShortcut(this.project, controller)) {
223223
processor.process(new NavigationItemEx(psiElement, name, Symfony2Icons.ROUTE, "Route"));

src/main/java/fr/adrienbrault/idea/symfony2plugin/action/comparator/ValueComparator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99
public class ValueComparator implements Comparator<String> {
1010

11-
Map<String, Integer> base;
11+
final Map<String, Integer> base;
1212

1313
public ValueComparator(Map<String, Integer> base) {
1414
this.base = base;

src/main/java/fr/adrienbrault/idea/symfony2plugin/action/generator/ServiceArgumentGenerateAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull Ps
6969
}
7070

7171
List<String> args = ServiceActionUtil.getXmlMissingArgumentTypes(serviceTag, true, new ContainerCollectionResolver.LazyServiceCollector(project));
72-
if (args.size() == 0) {
72+
if (args.isEmpty()) {
7373
return;
7474
}
7575

src/main/java/fr/adrienbrault/idea/symfony2plugin/action/ui/MethodParameter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
public class MethodParameter implements Serializable {
1414
public static class MethodModelParameter {
1515

16-
private Method method;
17-
private Parameter parameter;
18-
private int index;
19-
private Set<String> possibleServices;
16+
private final Method method;
17+
private final Parameter parameter;
18+
private final int index;
19+
private final Set<String> possibleServices;
2020
private boolean isPossibleService = false;
2121
private String currentService;
2222

src/main/java/fr/adrienbrault/idea/symfony2plugin/action/ui/ServiceArgumentSelectionDialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public ServiceParameter(String classFqn, Set<String> possibleServices) {
117117
this.classFqn = classFqn;
118118
this.possibleServices = possibleServices;
119119

120-
if(possibleServices.size() > 0) {
120+
if(!possibleServices.isEmpty()) {
121121
currentService = possibleServices.iterator().next();
122122
}
123123

src/main/java/fr/adrienbrault/idea/symfony2plugin/action/ui/ServiceBuilder.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public enum OutputType {
3939
Yaml, XML,
4040
}
4141

42-
private List<MethodParameter.MethodModelParameter> methodModelParameter;
43-
private Project project;
42+
private final List<MethodParameter.MethodModelParameter> methodModelParameter;
43+
private final Project project;
4444

4545
/**
4646
* Symfony 3.3 class name can be id attribute for services
@@ -117,7 +117,7 @@ private List<String> getParameters(List<MethodParameter.MethodModelParameter> me
117117

118118
}
119119

120-
if(!hasCall || methodCalls.size() == 0) {
120+
if(!hasCall || methodCalls.isEmpty()) {
121121
return null;
122122
}
123123

@@ -257,7 +257,7 @@ private String buildYaml(Map<String, List<MethodParameter.MethodModelParameter>>
257257
}
258258
}
259259

260-
if(calls.size() > 0) {
260+
if(!calls.isEmpty()) {
261261
lines.add(indent + "calls:");
262262
lines.addAll(calls);
263263
}
@@ -290,7 +290,7 @@ private void serviceTagCallback(String className, TagCallbackInterface callback)
290290
serviceTags.add(serviceTag);
291291
}
292292

293-
if(serviceTags.size() == 0) {
293+
if(serviceTags.isEmpty()) {
294294
return;
295295
}
296296

src/main/java/fr/adrienbrault/idea/symfony2plugin/action/ui/SymfonyCreateService.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ public class SymfonyCreateService extends JDialog {
7575
private Map<String, ContainerService> serviceClass;
7676
private Set<String> serviceSetComplete;
7777

78-
private Project project;
78+
private final Project project;
7979

8080
@Nullable
81-
private PsiFile psiFile;
81+
private final PsiFile psiFile;
8282

8383
@Nullable
84-
private Editor editor;
84+
private final Editor editor;
8585

8686
@Nullable
8787
private String classInit;
@@ -348,7 +348,7 @@ private void updateTask() {
348348
className = className.substring(1);
349349
}
350350

351-
if(className.length() == 0) {
351+
if(className.isEmpty()) {
352352
return;
353353
}
354354

@@ -368,7 +368,7 @@ private void updateTask() {
368368
Parameter[] parameters = method.getParameters();
369369
for (int i = 0; i < parameters.length; i++) {
370370
Set<String> possibleServices = getPossibleServices(parameters[i]);
371-
if(possibleServices.size() > 0) {
371+
if(!possibleServices.isEmpty()) {
372372
modelParameters.add(new MethodParameter.MethodModelParameter(method, parameters[i], i, possibleServices, getServiceName(possibleServices)));
373373
} else {
374374
modelParameters.add(new MethodParameter.MethodModelParameter(method, parameters[i], i, serviceSetComplete));
@@ -396,7 +396,7 @@ private void updateTask() {
396396

397397
@Nullable
398398
private String getServiceName(Set<String> services) {
399-
if(services.size() == 0) {
399+
if(services.isEmpty()) {
400400
return null;
401401
}
402402

src/main/java/fr/adrienbrault/idea/symfony2plugin/asset/AssetFile.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
*/
1010
public class AssetFile {
1111
@NotNull
12-
private VirtualFile assetFile;
12+
private final VirtualFile assetFile;
1313

1414
@NotNull
15-
private AssetEnum.Position assetPosition;
15+
private final AssetEnum.Position assetPosition;
1616

1717
@NotNull
1818
private VirtualFile relativeFolder;

src/main/java/fr/adrienbrault/idea/symfony2plugin/asset/AssetLookupElement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
* @author Adrien Brault <adrien.brault@gmail.com>
1414
*/
1515
public class AssetLookupElement extends LookupElement {
16-
protected AssetFile assetFile;
17-
protected Project project;
16+
protected final AssetFile assetFile;
17+
protected final Project project;
1818
protected InsertHandler<AssetLookupElement> insertHandler;
1919

2020
public AssetLookupElement(AssetFile assetfile, Project project) {

src/main/java/fr/adrienbrault/idea/symfony2plugin/assetMapper/AssetMapperUtil.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.jetbrains.annotations.NotNull;
2424

2525
import java.util.*;
26-
import java.util.function.Function;
2726
import java.util.stream.Collectors;
2827

2928
/**

src/main/java/fr/adrienbrault/idea/symfony2plugin/assistant/AssistantReferenceProvider.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ public interface AssistantReferenceProvider {
1717

1818
class AssistantReferenceProviderParameter {
1919

20-
private StringLiteralExpression psiElement;
21-
private MethodParameterSetting methodParameterSetting;
22-
private List<MethodParameterSetting> configsMethodScope;
23-
private MethodReference methodReference;
20+
private final StringLiteralExpression psiElement;
21+
private final MethodParameterSetting methodParameterSetting;
22+
private final List<MethodParameterSetting> configsMethodScope;
23+
private final MethodReference methodReference;
2424

2525
public AssistantReferenceProviderParameter(StringLiteralExpression psiElement, MethodParameterSetting methodParameterSetting, List<MethodParameterSetting> configsMethodScope, MethodReference methodReference) {
2626
this.psiElement = psiElement;

src/main/java/fr/adrienbrault/idea/symfony2plugin/assistant/reference/DefaultReferenceContributor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
public class DefaultReferenceContributor {
1313

1414
// @TODO: dynamic adding
15-
public static AssistantReferenceContributor[] DEFAULT_CONTRIBUTORS = new AssistantReferenceContributor[] {
15+
public static final AssistantReferenceContributor[] DEFAULT_CONTRIBUTORS = new AssistantReferenceContributor[] {
1616
new ParameterAssistantReferenceProvider(),
1717
new AssistantReferenceProviderConfigArray(),
1818
new AssistantReferenceProviderArrayKey()

src/main/java/fr/adrienbrault/idea/symfony2plugin/assistant/reference/DefaultReferenceProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
public class DefaultReferenceProvider {
2020

21-
public static AssistantReferenceProvider[] DEFAULT_PROVIDERS = new AssistantReferenceProvider[] {
21+
public static final AssistantReferenceProvider[] DEFAULT_PROVIDERS = new AssistantReferenceProvider[] {
2222
new RouteReferenceProvider(),
2323
new RepositoryReferenceProvider(),
2424
new TemplateProvider(),

src/main/java/fr/adrienbrault/idea/symfony2plugin/assistant/signature/MethodSignatureSetting.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class MethodSignatureSetting {
1616
private String ReferenceProviderName;
1717
private int indexParameter;
1818

19-
private AssistantPsiReferenceContributor assistantPsiReferenceContributor = null;
19+
private final AssistantPsiReferenceContributor assistantPsiReferenceContributor = null;
2020

2121
public MethodSignatureSetting() {
2222
}

src/main/java/fr/adrienbrault/idea/symfony2plugin/assistant/signature/PhpTypeSignatureTypes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
public class PhpTypeSignatureTypes {
2020

21-
public static PhpTypeSignatureInterface[] DEFAULT_PROVIDER = new PhpTypeSignatureInterface[] {
21+
public static final PhpTypeSignatureInterface[] DEFAULT_PROVIDER = new PhpTypeSignatureInterface[] {
2222
new ServiceType(),
2323
new ClassType(),
2424
new FormTypesType(),

src/main/java/fr/adrienbrault/idea/symfony2plugin/codeInsight/SymfonyImplicitUsageProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ private boolean isConstraint(@NotNull PhpClass phpClass) {
6363
// class in same namespace
6464
// @TODO: validateBy alias
6565
String className = phpClass.getFQN() + "Validator";
66-
return PhpElementsUtil.getClassesInterface(phpClass.getProject(), className).size() > 0;
66+
return !PhpElementsUtil.getClassesInterface(phpClass.getProject(), className).isEmpty();
6767
}
6868

6969
private boolean isEntityRepository(@NotNull PhpClass phpClass) {
7070
return PhpElementsUtil.isInstanceOf(phpClass, "\\Doctrine\\ORM\\EntityRepository")
71-
&& DoctrineMetadataUtil.findMetadataForRepositoryClass(phpClass).size() > 0;
71+
&& !DoctrineMetadataUtil.findMetadataForRepositoryClass(phpClass).isEmpty();
7272
}
7373

7474
private boolean isTwigExtension(PhpClass phpClass) {

src/main/java/fr/adrienbrault/idea/symfony2plugin/codeInspection/form/FormTypeAsClassConstantInspection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
public class FormTypeAsClassConstantInspection extends LocalInspectionTool {
2525

26-
public static String MESSAGE = "Use fully-qualified class name (FQCN)";
26+
public static final String MESSAGE = "Use fully-qualified class name (FQCN)";
2727

2828
@NotNull
2929
public PsiElementVisitor buildVisitor(final @NotNull ProblemsHolder holder, boolean isOnTheFly) {

src/main/java/fr/adrienbrault/idea/symfony2plugin/codeInspection/quickfix/CreateMethodQuickFix.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
public class CreateMethodQuickFix implements LocalQuickFix {
2525
@NotNull
26-
private SmartPsiElementPointer<PhpClass> smartPhpClass;
26+
private final SmartPsiElementPointer<PhpClass> smartPhpClass;
2727

2828
@NotNull
2929
private final String functionName;

src/main/java/fr/adrienbrault/idea/symfony2plugin/codeInspection/service/TaggedExtendsInterfaceClassInspection.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private void visitYamlElement(@NotNull PsiElement psiElement, @NotNull ProblemsH
104104
PsiElement serviceKeyValue = yamlCompoundValue.getParent();
105105
if (serviceKeyValue instanceof YAMLKeyValue) {
106106
Set<String> tags = YamlHelper.collectServiceTags((YAMLKeyValue) serviceKeyValue);
107-
if (tags.size() > 0) {
107+
if (!tags.isEmpty()) {
108108
registerTaggedProblems(psiElement, tags, text, holder, lazyServiceCollector);
109109
}
110110
}
@@ -117,7 +117,7 @@ private void visitYamlElement(@NotNull PsiElement psiElement, @NotNull ProblemsH
117117
PsiElement yamlKeyValue = psiElement.getParent();
118118
if (yamlKeyValue instanceof YAMLKeyValue && YamlHelper.getYamlKeyValue((YAMLKeyValue) yamlKeyValue, "resource") == null && YamlHelper.getYamlKeyValue((YAMLKeyValue) yamlKeyValue, "exclude") == null) {
119119
Set<String> tags = YamlHelper.collectServiceTags((YAMLKeyValue) yamlKeyValue);
120-
if (tags.size() > 0) {
120+
if (!tags.isEmpty()) {
121121
registerTaggedProblems(psiElement, tags, text, holder, lazyServiceCollector);
122122
}
123123
}
@@ -126,7 +126,7 @@ private void visitYamlElement(@NotNull PsiElement psiElement, @NotNull ProblemsH
126126
}
127127

128128
private void registerTaggedProblems(@NotNull PsiElement source, @NotNull Set<String> tags, @NotNull String serviceClass, @NotNull ProblemsHolder holder, @NotNull NotNullLazyValue<ContainerCollectionResolver.LazyServiceCollector> lazyServiceCollector) {
129-
if (tags.size() == 0) {
129+
if (tags.isEmpty()) {
130130
return;
131131
}
132132

src/main/java/fr/adrienbrault/idea/symfony2plugin/completion/ConstantEnumCompletionContributor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @author Daniel Espendiller <daniel@espendiller.net>
2020
*/
2121
public class ConstantEnumCompletionContributor extends CompletionContributor {
22-
public static ConstantEnumCompletionProvider[] CONSTANTS_ENUMS = new ConstantEnumCompletionProvider[] {
22+
public static final ConstantEnumCompletionProvider[] CONSTANTS_ENUMS = new ConstantEnumCompletionProvider[] {
2323
new ConstantEnumCompletionProvider(
2424
new MethodMatcher.CallToSignature("\\Symfony\\Component\\HttpFoundation\\Response", "setStatusCode"),
2525
new EnumConstantFilter("\\Symfony\\Component\\HttpFoundation\\Response", "HTTP_"),

src/main/java/fr/adrienbrault/idea/symfony2plugin/completion/IncompletePropertyServiceInjectionContributor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ protected void addCompletions(@NotNull CompletionParameters completionParameters
155155
}
156156

157157
Collection<PhpClass> anyByFQN = PhpIndex.getInstance(originalPosition.getProject()).getAnyByFQN(fqn);
158-
if (anyByFQN.size() == 0) {
158+
if (anyByFQN.isEmpty()) {
159159
continue;
160160
}
161161

@@ -185,7 +185,7 @@ protected void addCompletions(@NotNull CompletionParameters completionParameters
185185
String fqn = injection.getSecond();
186186

187187
Collection<PhpClass> anyByFQN = PhpIndex.getInstance(originalPosition.getProject()).getAnyByFQN(fqn);
188-
if (anyByFQN.size() == 0) {
188+
if (anyByFQN.isEmpty()) {
189189
continue;
190190
}
191191

@@ -281,7 +281,7 @@ public static List<String> getInjectionService(@NotNull Project project, @NotNul
281281
for (String property : propertyNameFind) {
282282
if (alias.containsKey(property.toLowerCase())) {
283283
String key = property.toLowerCase();
284-
if (PhpIndex.getInstance(project).getAnyByFQN(alias.get(key)).size() > 0) {
284+
if (!PhpIndex.getInstance(project).getAnyByFQN(alias.get(key)).isEmpty()) {
285285
String fqn = alias.get(key);
286286
servicesMatch.put(fqn, new Match(fqn, 4));
287287
}
@@ -353,7 +353,7 @@ public static List<String> getInjectionService(@NotNull Project project, @NotNul
353353
}
354354

355355
Collection<PhpClass> anyByFQN = PhpIndex.getInstance(project).getAnyByFQN(fqn);
356-
if (anyByFQN.size() == 0) {
356+
if (anyByFQN.isEmpty()) {
357357
continue;
358358
}
359359

@@ -429,14 +429,14 @@ private String getCompletedText(@NotNull CompletionParameters completionParamete
429429
PsiElement originalPosition = completionParameters.getOriginalPosition();
430430
if (originalPosition != null) {
431431
String text = originalPosition.getText();
432-
if (text.length() > 0) {
432+
if (!text.isEmpty()) {
433433
return text;
434434
}
435435
}
436436

437437
PsiElement position = completionParameters.getPosition();
438438
String text = position.getText().toLowerCase().replace("intellijidearulezzz", "");
439-
if (text.length() > 0) {
439+
if (!text.isEmpty()) {
440440
return text;
441441
}
442442

src/main/java/fr/adrienbrault/idea/symfony2plugin/completion/PhpIncompleteCompletionContributor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void handleInsert(@NotNull InsertionContext context, @NotNull com.intelli
104104
}
105105

106106
Set<Map.Entry<String, String>> entries = options.entrySet();
107-
if (entries.size() > 0) {
107+
if (!entries.isEmpty()) {
108108
content += ", [";
109109

110110
List<String> opts = new ArrayList<>();

0 commit comments

Comments
 (0)