Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"lexicographic" parameter sometimes ignored in ImportsChecker #352

Open
nrinaudo opened this issue Dec 19, 2019 · 0 comments
Open

"lexicographic" parameter sometimes ignored in ImportsChecker #352

nrinaudo opened this issue Dec 19, 2019 · 0 comments

Comments

@nrinaudo
Copy link

Steps to reproduce

Have a file containing the following import statement:

import java.time.{ZoneOffset, ZonedDateTime}

And run scalastyle with the following configuration:

  <check class="org.scalastyle.scalariform.ImportOrderChecker"               level="error"   enabled="true">
    <parameters>
      <parameter name="groups">all</parameter>
      <parameter name="group.all">.+</parameter>
      <parameter name="lexicographic">true</parameter>
    </parameters>
  </check>

Expected behaviour

Scalastyle should not find an issue

Observed behaviour

Scalastyle complains:

ZonedDateTime should come before ZoneOffset.

Notes

I believe this is a bug because it seems to contradict the lexicographic parameter's documentation:

 *  - lexicographic: if true, imports are ordered lexicographically (classes, wildcards, then
 *                   packages; case-sensitive ordering within); 

It also disagrees with tools such as scalafmt - and having scalafmt and scalastyle disagreeing on how things should be ordered is not fun.

I'm happy to submit a PR for this issue - it looks like a simple omission in compareNames in the case isImport=false, which ignores the value of lexicographic and will always compareIgnoreCase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant