Skip to content

Commit

Permalink
Issue checkstyle#7876: Fix for ImportOrderChec(6)
Browse files Browse the repository at this point in the history
  • Loading branch information
yajna-pandith committed Mar 20, 2020
1 parent 53cddfd commit aa80534
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 @@ -80,7 +80,6 @@ pitest-imports)
"ImportOrderCheck.java.html:<td class='covered'><pre><span class='survived'> final boolean separatorBetween = isStatic != lastImportStatic</span></pre></td></tr>"
"ImportOrderCheck.java.html:<td class='covered'><pre><span class='survived'> if (caseSensitive) {</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 aa80534

Please sign in to comment.