forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Scalafix (pantsbuild#20394)
Implemented for `fix` and `lint` goals.
- Loading branch information
1 parent
548ef90
commit e4532cb
Showing
27 changed files
with
5,179 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
rules = [ | ||
NoAutoTupling, | ||
DisableSyntax, | ||
NoValInForComprehension, | ||
RedundantSyntax, | ||
RemoveUnused, | ||
ProcedureSyntax | ||
] | ||
|
||
DisableSyntax.noThrows = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright 2024 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
python_sources() |
Empty file.
4 changes: 4 additions & 0 deletions
4
src/python/pants/backend/experimental/scala/lint/scalafix/BUILD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright 2023 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
python_sources() |
Empty file.
14 changes: 14 additions & 0 deletions
14
src/python/pants/backend/experimental/scala/lint/scalafix/register.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright 2024 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from pants.backend.experimental.scala.register import rules as all_scala_rules | ||
from pants.backend.scala.lint.scalafix import extra_fields | ||
from pants.backend.scala.lint.scalafix import rules as scalafix_rules | ||
|
||
|
||
def rules(): | ||
return [ | ||
*all_scala_rules(), | ||
*scalafix_rules.rules(), | ||
*extra_fields.rules(), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright 2023 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
python_sources(dependencies=[":lockfile"]) | ||
|
||
python_tests(name="tests", dependencies=[":test-lockfiles"]) | ||
|
||
resource(name="lockfile", source="scalafix.default.lockfile.txt") | ||
|
||
resources(name="test-lockfiles", sources=["*.test.lock"]) |
Empty file.
15 changes: 15 additions & 0 deletions
15
src/python/pants/backend/scala/lint/scalafix/extra_fields.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright 2023 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from pants.backend.scala.target_types import SCALA_SOURCES_TARGET_TYPES | ||
from pants.engine.target import BoolField | ||
|
||
|
||
class SkipScalafixField(BoolField): | ||
alias = "skip_scalafix" | ||
default = False | ||
help = "If true, don't run `scalafix` on this target's code." | ||
|
||
|
||
def rules(): | ||
return [tgt.register_plugin_field(SkipScalafixField) for tgt in SCALA_SOURCES_TARGET_TYPES] |
Oops, something went wrong.