Created
January 17, 2020 09:45
-
-
Save REDNBLACK/e8bbb33ee7bd80757f29a6542fb0080c to your computer and use it in GitHub Desktop.
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
rules = [ | |
Disable, | |
DisableSyntax, | |
ExplicitResultTypes, | |
LeakingImplicitClassVal, | |
NoValInForComprehension, | |
ProcedureSyntax | |
] | |
Disable { | |
symbols = [ | |
{ | |
id = "scala.io.Source" | |
symbol = "scala.io.Source", | |
message = "Use java.nio instead, legacy API" | |
}, | |
{ | |
id = "Enumeration" | |
symbol = "scala.Enumeration" | |
message = "Use Enumeratum instead, legacy API" | |
}, | |
{ | |
id = "ScalaCollection", | |
regex.includes = [ | |
// "scala.collection.Seq", | |
"scala.collection.immutable.Stream", | |
"scala.collection.mutable.*", | |
"scala.collection.parallel.*" | |
], | |
message = "Do not use, mutable structure, worse peformance, dead-locks" | |
}, | |
{ | |
id = "ScalaMath", | |
regex.includes = [ | |
"scala.math.BigDecimal", | |
"scala.math.BigInt" | |
], | |
message = "Use java.math instead, arbitrary precision numbers are broken: https://github.com/scala/bug/issues/9670" | |
}, | |
{ | |
id = "ScalaPartial", | |
regex.includes = [ | |
"^\\Qscala/Option#get().\\E$", | |
"^\\Qscala/Some#get().\\E$", | |
"^\\Qscala/None#get().\\E$", | |
"^\\Qscala/util/Try#get().\\E$", | |
"^\\Qscala/util/Failure#get().\\E$", | |
"^\\Qscala/util/Success#get().\\E$", | |
"^\\Qscala/util/Either.LeftProjection#get().\\E$", | |
"^\\Qscala/util/Either.RightProjection#get().\\E$" | |
], | |
message = "Use .fold or .getOrElse instead, not a total function" | |
}, | |
{ | |
id = "ScalaPartial", | |
regex.includes = [ | |
"^scala\\/collection\\/((immutable\\/)*?).+#head\\(\\)\\.$", | |
"^scala\\/collection\\/((immutable\\/)*?).+#tail\\(\\)\\.$", | |
"^scala\\/collection\\/((immutable\\/)*?).+#init\\(\\)\\.$", | |
"^scala\\/collection\\/((immutable\\/)*?).+#last\\(\\)\\.$", | |
"^scala\\/collection\\/((immutable\\/)*?).+#reduce\\(\\)\\.$", | |
"^scala\\/collection\\/((immutable\\/)*?).+#reduceLeft\\(\\)\\.$", | |
"^scala\\/collection\\/((immutable\\/)*?).+#reduceRight\\(\\)\\.$", | |
"^scala\\/collection\\/((immutable\\/)*?).+#min\\(\\)\\.$", | |
"^scala\\/collection\\/((immutable\\/)*?).+#minBy\\(\\)\\.$", | |
"^scala\\/collection\\/((immutable\\/)*?).+#max\\(\\)\\.$", | |
"^scala\\/collection\\/((immutable\\/)*?).+#maxBy\\(\\)\\.$", | |
], | |
message = "Use .headOption, .lastOption, .foldLeft or similar instead, not a total function" | |
} | |
{ | |
id = "URL", | |
symbol = "java.net.URL", | |
message = "Use java.net.URI instead, java.net.URL talks to the network for equality" | |
}, | |
{ | |
id = "equals", | |
regex.includes = ["^.*\\Q#equals().\\E$"], | |
message = "Use cats.Eq instead" | |
}, | |
{ | |
id = "hashCode", | |
regex.includes = ["^.*\\Q#hashCode().\\E$"], | |
message = "Use cats.Hash instead" | |
}, | |
// { | |
// id = "toString", | |
// regex.includes = ["^.*\\Q#toString().\\E$"], | |
// message = "Use cats.Show instead" | |
// }, | |
] | |
ifSynthetic = [ | |
{ | |
id = "Any2String", | |
symbol = "scala.Predef.any2stringadd", | |
message = "Use explicit .toString instead" | |
}, | |
// { | |
// id = "Option2Iterable", | |
// symbol = "scala.Option.option2Iterable", | |
// message = "Use .fold instead, this can hide bugs and creates surprising situations like Some(1) zip Some(2) returning an Iterable[(Int, Int)]." | |
// }, | |
{ | |
id = "Serializable", | |
symbol = "java.io.Serializable", | |
message = "Illegal inferred type" | |
}, | |
// { | |
// id = "Any", | |
// symbol = "scala.Any", | |
// message = "Illegal inferred type" | |
// }, | |
// { | |
// id = "Product", | |
// symbol = "scala.Product", | |
// message = "Illegal inferred type" | |
// }, | |
{ | |
// Carefull https://github.com/scalacenter/scalafix/issues/703 | |
id = "ScalaPartial", | |
regex.includes = [ | |
"scala.collection.MapLike.apply", | |
"scala.collection.SeqLike.apply", | |
"scala.collection.LinearSeqOptimized.apply", | |
"scala.collection.immutable.Vector.apply", | |
], | |
message = "Do not use, not a total function" | |
} | |
] | |
} | |
DisableSyntax { | |
noVars = true | |
noThrows = true | |
noNulls = true | |
noFinalize = true | |
noReturns = true | |
noWhileLoops = true | |
noAsInstanceOf = true | |
noIsInstanceOf = true | |
noXml = true | |
noValPatterns = true | |
// noFinalVal = true // https://github.com/sbt/zinc/issues/227 | |
noDefaultArgs = false | |
// noUniversalEquality = true | |
// noUniversalEqualityMessage = "use === instead of ==" | |
regex = [ | |
{ | |
id = "offensive" | |
pattern = "[Pp]imp" | |
message = "Please consider a less offensive word such as 'extension' or 'enrichment'" | |
} | |
] | |
} | |
ExplicitResultTypes { | |
memberKind = [Def, Val, Var] | |
memberVisibility = [Public] | |
skipSimpleDefinitions = ['Term.Ref', 'Lit', 'Term.New'] | |
skipLocalImplicits = true | |
fatalWarnings = false | |
rewriteStructuralTypesToNamedSubclass = true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment