Skip to content

Commit

Permalink
Issue #7876: Fix for ImportOrderChec(6)
Browse files Browse the repository at this point in the history
  • Loading branch information
yajna-pandith authored and romani committed May 28, 2020
1 parent 6275303 commit 3dfe9c8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 0 additions & 1 deletion .ci/pitest.sh
Expand Up @@ -73,7 +73,6 @@ pitest-imports)
"ImportControlLoader.java.html:<td class='covered'><pre><span class='survived'> else if (ALLOW_ELEMENT_NAME.equals(qName) || &#34;disallow&#34;.equals(qName)) {</span></pre></td></tr>"
"ImportOrderCheck.java.html:<td class='covered'><pre><span class='survived'> else if (matcher.start() == bestPos &#38;&#38; matcher.end() &#62; bestEnd) {</span></pre></td></tr>"
"ImportOrderCheck.java.html:<td class='covered'><pre><span class='survived'> if (!CommonUtil.endsWithChar(pkg, &#39;.&#39;)) {</span></pre></td></tr>"
"ImportOrderCheck.java.html:<td class='covered'><pre><span class='survived'> if (isStatic) {</span></pre></td></tr>"
"ImportOrderCheck.java.html:<td class='covered'><pre><span class='survived'> return !beforeFirstImport &#38;&#38; line - lastImportLine &#62; 1;</span></pre></td></tr>"
"ImportOrderCheck.java.html:<td class='covered'><pre><span class='survived'> staticImportSeparator = isStatic &#38;&#38; separated;</span></pre></td></tr>"
"PkgImportControl.java.html:<td class='covered'><pre><span class='survived'> if (alreadyRegex) {</span></pre></td></tr>"
Expand Down
Expand Up @@ -71,6 +71,23 @@ public void testDefault() throws Exception {
verify(checkConfig, getNonCompilablePath("InputImportOrder.java"), expected);
}

@Test
public void testWrongSequenceInNonStaticImports() throws Exception {
final DefaultConfiguration checkConfig =
createModuleConfig(ImportOrderCheck.class);
checkConfig.addAttribute("useContainerOrderingForStatic", "false");
checkConfig.addAttribute("sortStaticImportsAlphabetically", "false");
checkConfig.addAttribute("option", "bottom");

final String[] expected = {
"4:1: " + getCheckMessage(MSG_ORDERING,
"java.util.HashMap"),
};

verify(checkConfig,
getNonCompilablePath("InputImportOrderNonStaticWrongSequence.java"), expected);
}

@Test
public void testMultilineImport() throws Exception {
final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class);
Expand Down
@@ -0,0 +1,9 @@
package com.puppycrawl.tools.checkstyle.checks.imports.importorder;

import java.util.LinkedList;
import java.util.HashMap;

class InputImportOrderNonStaticWrongSequence {
}


0 comments on commit 3dfe9c8

Please sign in to comment.