chipsalliance / chipsalliance/rocket-chip
Code style, scalafix, and scalafmt discussion.
- Dominant language
- Scala
- Stars
- 3.9k
- Forks
- 1.3k
- Avg merge
- 5d 13m
- Merged PRs (30d)
- 1
Description
Expanding on the discussion happening in https://github.com/chipsalliance/rocket-chip/pull/3593 here.
*discussion summary*
I'd like to propose reducing/removing wildcard imports where we can. It generally helps with presenting context and making the side effects of implicits more explicit.
Possible Options for wildcards:
1. Be explicit until we hit some threshold then coalesce to wildcard
2. always be explicit about imports but configure scalafmt to make them more compact. Also provide info on import folding for IDEs.
3. Be explicit about imports, and if we use a lot from some other code base, namespace the useage of those things instead of wildcard importing.
In any of the above scenarios i think at a minimum we should move to explicitly importing implicits that are use just for clarity and potential safety.
As part of this i think we should also start figuring out a consistent set of guidelines and scalafix/fmt rules for this project.
The goal is to ease code maintenance burdens and do a big clean up on the project to get it all into a consistent style. Overall these changes help with readability as well.
Below is the basic scalafix config i've been using to help me clean up imports.
```
rules = [
// RemoveUnused,
DisableSyntax,
LeakingImplicitClassVal,
NoAutoTupling,
NoValInForComprehension,
ProcedureSyntax,
OrganizeImports,
]
// OrganizeImports Config
OrganizeImports {
blankLines = Auto
groups = [
"chisel3.",
"hardfloat.",
"org.chipsalliance.",
"freechips.rocketchip.",
"scala.",
"scala.meta.",
"*"
]
groupedImports = Merge
groupExplicitlyImportedImplicitsSeparately = true
coalesceToWildcardImportThreshold = null
expandRelative = true
removeUnused = false
}
```
@jerryrzhao @sequencer would greatly appreciate your ideas/input here.
**Type of issue**: other enhancement
**Impact**: no functional change
**Development Phase**: proposal
Contributor guide
Assessment
This issue has not been assessed yet.