diff --git a/plugins/env-files-support/src/main/java/ru/adelf/idea/dotenv/inspections/DuplicateKeyInspection.java b/plugins/env-files-support/src/main/java/ru/adelf/idea/dotenv/inspections/DuplicateKeyInspection.java
index 5acc7753ee2e..0faead0b4c81 100644
--- a/plugins/env-files-support/src/main/java/ru/adelf/idea/dotenv/inspections/DuplicateKeyInspection.java
+++ b/plugins/env-files-support/src/main/java/ru/adelf/idea/dotenv/inspections/DuplicateKeyInspection.java
@@ -15,6 +15,14 @@ import ru.adelf.idea.dotenv.psi.DotEnvFile;
import java.util.*;
public class DuplicateKeyInspection extends LocalInspectionTool {
+ // Change the display name within the plugin.xml
+ // This needs to be here as otherwise the tests will throw errors.
+ @NotNull
+ @Override
+ public String getDisplayName() {
+ return "Duplicate Key";
+ }
+
@Override
public boolean runForWholeFile() {
return true;
diff --git a/plugins/env-files-support/src/main/java/ru/adelf/idea/dotenv/inspections/ExtraBlankLineInspection.java b/plugins/env-files-support/src/main/java/ru/adelf/idea/dotenv/inspections/ExtraBlankLineInspection.java
new file mode 100644
index 000000000000..d32690be0222
--- /dev/null
+++ b/plugins/env-files-support/src/main/java/ru/adelf/idea/dotenv/inspections/ExtraBlankLineInspection.java
@@ -0,0 +1,91 @@
+package ru.adelf.idea.dotenv.inspections;
+
+import com.intellij.codeInspection.*;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.impl.source.tree.ElementType;
+import com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import ru.adelf.idea.dotenv.DotEnvFactory;
+import ru.adelf.idea.dotenv.psi.DotEnvFile;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class ExtraBlankLineInspection extends LocalInspectionTool {
+ // Change the display name within the plugin.xml
+ // This needs to be here as otherwise the tests will throw errors.
+ @NotNull
+ @Override
+ public String getDisplayName() {
+ return "Extra blank line";
+ }
+
+ @Override
+ public boolean runForWholeFile() {
+ return true;
+ }
+
+ @Nullable
+ @Override
+ public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
+ if (!(file instanceof DotEnvFile)) {
+ return null;
+ }
+
+ return analyzeFile(file, manager, isOnTheFly).getResultsArray();
+ }
+
+ @NotNull
+ private ProblemsHolder analyzeFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
+ ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, isOnTheFly);
+
+ PsiTreeUtil.findChildrenOfType(file, PsiWhiteSpaceImpl.class).forEach(whiteSpace -> {
+ Pattern pattern = Pattern.compile("\r\n|\r|\n");
+ Matcher matcher = pattern.matcher(whiteSpace.getText());
+
+ int count = 0;
+ while (matcher.find())
+ count++;
+
+ if (count > 2) {
+ problemsHolder.registerProblem(whiteSpace,
+ "Only one extra line allowed between properties",
+ new RemoveExtraBlankLineQuickFix());
+ }
+ });
+
+ return problemsHolder;
+ }
+
+ private static class RemoveExtraBlankLineQuickFix implements LocalQuickFix {
+
+ @NotNull
+ @Override
+ public String getName() {
+ return "Remove extra blank line";
+ }
+
+ public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
+ try {
+ PsiElement psiElement = descriptor.getPsiElement();
+
+ PsiElement newPsiElement = DotEnvFactory.createFromText(project, ElementType.WHITE_SPACE, "\n\n");
+
+ psiElement.replace(newPsiElement);
+ } catch (IncorrectOperationException e) {
+ Logger.getInstance(ExtraBlankLineInspection.class).error(e);
+ }
+ }
+
+ @NotNull
+ public String getFamilyName() {
+ return getName();
+ }
+ }
+}
diff --git a/plugins/env-files-support/src/main/java/ru/adelf/idea/dotenv/inspections/IncorrectDelimiterInspection.java b/plugins/env-files-support/src/main/java/ru/adelf/idea/dotenv/inspections/IncorrectDelimiterInspection.java
new file mode 100644
index 000000000000..11d5f17c832e
--- /dev/null
+++ b/plugins/env-files-support/src/main/java/ru/adelf/idea/dotenv/inspections/IncorrectDelimiterInspection.java
@@ -0,0 +1,80 @@
+package ru.adelf.idea.dotenv.inspections;
+
+import com.intellij.codeInspection.*;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import ru.adelf.idea.dotenv.DotEnvFactory;
+import ru.adelf.idea.dotenv.psi.DotEnvFile;
+import ru.adelf.idea.dotenv.psi.DotEnvTypes;
+import ru.adelf.idea.dotenv.psi.impl.DotEnvKeyImpl;
+
+public class IncorrectDelimiterInspection extends LocalInspectionTool {
+ // Change the display name within the plugin.xml
+ // This needs to be here as otherwise the tests will throw errors.
+ @NotNull
+ @Override
+ public String getDisplayName() {
+ return "Incorrect delimiter";
+ }
+
+ @Override
+ public boolean runForWholeFile() {
+ return true;
+ }
+
+ @Nullable
+ @Override
+ public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
+ if (!(file instanceof DotEnvFile)) {
+ return null;
+ }
+
+ return analyzeFile(file, manager, isOnTheFly).getResultsArray();
+ }
+
+ @NotNull
+ private ProblemsHolder analyzeFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
+ ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, isOnTheFly);
+
+ PsiTreeUtil.findChildrenOfType(file, DotEnvKeyImpl.class).forEach(key -> {
+ if (key.getText().contains("-")) {
+ problemsHolder.registerProblem(key, "Expected: '_' Found: '-'", new ReplaceDelimiterQuickFix());
+ }
+ });
+
+ return problemsHolder;
+ }
+
+ private static class ReplaceDelimiterQuickFix implements LocalQuickFix {
+
+ @NotNull
+ @Override
+ public String getName() {
+ return "Replace delimiter";
+ }
+
+ public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
+ try {
+ PsiElement psiElement = descriptor.getPsiElement();
+
+ PsiElement newPsiElement = DotEnvFactory.createFromText(project, DotEnvTypes.KEY,
+ psiElement.getText().replace("-","_")+"=dummy");
+
+ psiElement.replace(newPsiElement);
+ } catch (IncorrectOperationException e) {
+ Logger.getInstance(IncorrectDelimiterInspection.class).error(e);
+ }
+ }
+
+ @NotNull
+ public String getFamilyName() {
+ return getName();
+ }
+ }
+}
diff --git a/plugins/env-files-support/src/main/java/ru/adelf/idea/dotenv/inspections/SpaceInsideNonQuotedInspection.java b/plugins/env-files-support/src/main/java/ru/adelf/idea/dotenv/inspections/SpaceInsideNonQuotedInspection.java
index 65d37553e128..bfaae7f21ba3 100644
--- a/plugins/env-files-support/src/main/java/ru/adelf/idea/dotenv/inspections/SpaceInsideNonQuotedInspection.java
+++ b/plugins/env-files-support/src/main/java/ru/adelf/idea/dotenv/inspections/SpaceInsideNonQuotedInspection.java
@@ -16,6 +16,13 @@ import ru.adelf.idea.dotenv.psi.DotEnvTypes;
import ru.adelf.idea.dotenv.psi.DotEnvValue;
public class SpaceInsideNonQuotedInspection extends LocalInspectionTool {
+ // Change the display name within the plugin.xml
+ // This needs to be here as otherwise the tests will throw errors.
+ @NotNull
+ @Override
+ public String getDisplayName() {
+ return "Space inside non-quoted value";
+ }
private AddQuotesQuickFix addQuotesQuickFix = new AddQuotesQuickFix();
diff --git a/plugins/env-files-support/src/main/resources/META-INF/plugin.xml b/plugins/env-files-support/src/main/resources/META-INF/plugin.xml
index 1fa17964e851..cc455e50a3ac 100644
--- a/plugins/env-files-support/src/main/resources/META-INF/plugin.xml
+++ b/plugins/env-files-support/src/main/resources/META-INF/plugin.xml
@@ -102,6 +102,22 @@
level="WARNING"
implementationClass="ru.adelf.idea.dotenv.inspections.SpaceInsideNonQuotedInspection"/>
+