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

Add support for linters #291

Merged
merged 18 commits into from
Aug 18, 2017
Merged

Add support for linters #291

merged 18 commits into from
Aug 18, 2017

Commits on Aug 18, 2017

  1. Replace sourcecode.Name with scalafix.rewrite.RewriteName.

    RewriteName is a wrapper around a non-empty list of strings instead of
    being a single string. Original names are preserved when composing
    multiple RewriteNames.
    olafurpg committed Aug 18, 2017
    Configuration menu
    Copy the full SHA
    a9ff6a0 View commit details
    Browse the repository at this point in the history
  2. Add infrastructure for linters, towards scalacenter#92.

    New package scalafix.lint with data structures for emitting messages
    from linters:
    - LintID: uniquely identifies a certain kind of linter message,
      owned by a rewrite. A LintID is attached to a default warning/error
      severity but can be configured to another category with
      `lint.ignore/warning/error = [ LintID ]`
    - LintMessage: an instance of LintID with a customized message at a
      particular position. A LintMessage can be created wit
      LintID.at(String/Position).
    - A LintMessage can be turned into a Patch with ctx.lint(LintMessage).
      LintMessages don't report to the console until Rewrite.apply is
      called.
    To accommodate linter development, scalafix-testkit now enforces that
    expected warnings/errors are documented in the input sources with
    a trailing `// scalafix: error/warning` comment.
    
    scalafix-cli returns a non-zero exit code of kind "LinterError" when a
    linter reports an error.
    olafurpg committed Aug 18, 2017
    Configuration menu
    Copy the full SHA
    ecab461 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a014ff4 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    6e5b915 View commit details
    Browse the repository at this point in the history
  5. Add LintCategory.Info

    olafurpg committed Aug 18, 2017
    Configuration menu
    Copy the full SHA
    9f11786 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    33ec950 View commit details
    Browse the repository at this point in the history
  7. Refactor RewriteName.

    - RewriteName is a list of RewriteIdentifier.
    - RewriteIdentifier is a name + optional deprecation warning. This makes
      it possible to rename a rewrite without breaking peoples config.
    - Rewrite.empty has name RewriteName.empty, which is an empty list of
      RewriteIdentifier.
    olafurpg committed Aug 18, 2017
    Configuration menu
    Copy the full SHA
    c95f1b2 View commit details
    Browse the repository at this point in the history
  8. Emit deprecation warnings when referencing a rewrite by old name.

    This change allows rewrites to change their names without breaking
    compatibility. Users using the old name will receive deprecation
    warnings and have opportunity to switch to the new name.
    olafurpg committed Aug 18, 2017
    Configuration menu
    Copy the full SHA
    9aec7a0 View commit details
    Browse the repository at this point in the history
  9. Move cli/test to unit/testOnly *cli*.

    unit/test has fixtures to build SemanticCtx, which will come in handy to
    test the cli.
    olafurpg committed Aug 18, 2017
    Configuration menu
    Copy the full SHA
    dcacac5 View commit details
    Browse the repository at this point in the history
  10. Rewrite CliTest with StringFS.

    The cli tests have in need for a rewrite for a long time.
    This commits creates a helper method to easily construct a fixture
    and run assertions against the expected output.
    olafurpg committed Aug 18, 2017
    Configuration menu
    Copy the full SHA
    6433616 View commit details
    Browse the repository at this point in the history
  11. Remove LintID.owner.

    Instead of using LintID.owner, the RewriteCtx.printMessages takes an
    `owner: RewriteName` argument. This results  in a simpler LintID data
    structure.
    olafurpg committed Aug 18, 2017
    Configuration menu
    Copy the full SHA
    e43b4b0 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    c0bd9f4 View commit details
    Browse the repository at this point in the history
  13. s/LintCategory/LintSeverity/

    "Category" is misleading.
    olafurpg committed Aug 18, 2017
    Configuration menu
    Copy the full SHA
    275bdf0 View commit details
    Browse the repository at this point in the history
  14. s/LintID/LintCategory/

    LintCategory is more suitable since it is a category of LintMessages.
    olafurpg committed Aug 18, 2017
    Configuration menu
    Copy the full SHA
    5d38cf6 View commit details
    Browse the repository at this point in the history
  15. Add test for deprecated names, VolatileLazyVal => DottyVolatileLazyVal.

    I've been meaning to rename this rewrite for a while but wasn't
    satisfied that this would break people's configuraiton. I wanted
    to solve this potentially common problem in the future more elegantly.
    
    Now that rewrites can have multiple names and names can have deprecation
    warnings, this commits tests that it indeed works as expected.
    olafurpg committed Aug 18, 2017
    Configuration menu
    Copy the full SHA
    6de3ac8 View commit details
    Browse the repository at this point in the history
  16. Last minute changes.

    - doc polish
    - Require `// scalafix: Rewrite.LintCategory` assertions instead
      of warning/error. This is more robust.
    - Rename VolatileLazyVal to DottyVolatileLazyVal in tests, I noticed
      because of deprecation warnings getting printed out.
    - Don't print out lint messages in scalafix-testkit by default,
      if you have a lot of assertions then the console gets flooded
      with too many messages.
    olafurpg committed Aug 18, 2017
    Configuration menu
    Copy the full SHA
    0bbaf08 View commit details
    Browse the repository at this point in the history
  17. Clean up before merge

    - remove unused imports with scalafix (hurray!)
    - refactor build.sbt a bit
    - polish new doc entries
    - Remove unused Patch.applyInternal
    olafurpg committed Aug 18, 2017
    Configuration menu
    Copy the full SHA
    9798839 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    b8e85db View commit details
    Browse the repository at this point in the history