This repository has been archived by the owner on May 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
scalafix.conf
226 lines (210 loc) · 6.17 KB
/
scalafix.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# Copyright: 2018 Sam Halliday
# License: https://www.apache.org/licenses/LICENSE-2.0
# This file enforces the scalazzi safe subset of scala.
#
# For further information, see https://github.com/scalaz/scalazzi
rules = [
Disable
DisableSyntax
ExplicitResultTypes
LeakingImplicitClassVal
MissingFinal
NoAutoTupling
NoValInForComprehension
ProcedureSyntax
RemoveUnused
]
Disable.symbols = [
{
regex = "^\\Qscala/collection/mutable\\E.*$"
message = "Java collections have better performance, which is what I assume you were trying to do"
}
{
regex = "^\\Qscala/collection/parallel\\E.*$"
message = "parallel collections are low performance and block the thread, prefer scalaz.ApplyN"
}
{
regex = "^\\Qscala/math/Big\\E.*$"
message = "scala arbitrary precision numbers are broken: https://github.com/scala/bug/issues/9670"
}
{
regex = {
includes = [
"^\\Qjava/io\\E.*$"
"^\\Qscala/io/Source\\E.*$"
]
}
message = "legacy blocking API, prefer java.nio"
}
{
regex = "^\\Qjava/net/URL#\\E.*$"
message = "URL talks to the network for equality, prefer URI"
}
{
regex = {
includes = [
# overrides not fully implemented: https://github.com/scalacenter/scalafix/pull/634
"^.*\\Q#equals().\\E$"
"^.*\\Q#hashCode().\\E$"
"^.*\\Q#toString().\\E$" # doesn't catch string interpolators...
# more to add here...
]
}
message = "prefer scalaz.{Equal, Show, Liskov, etc}"
}
{
symbol = "scala/Enumeration"
message = "prefer a sealed abstract class"
}
{
regex = {
includes = [
"^\\Qscala/util/Either.LeftProjection#get().\\E$"
"^\\Qscala/util/Either.RightProjection#get().\\E$"
"^\\Qscala/util/Try#get().\\E$"
"^\\Qscala/Option#get().\\E$"
"^\\Qscala/collection/IterableLike#head().\\E$"
]
}
message = "not a total function"
}
]
Disable.ifSynthetic = [
"java/io/Serializable"
"scala/Any"
"scala/Product"
# local type inference + covariant types fires this
# "scala/Nothing"
# when upstream broke noImplicitConversion and we don't agree that their
# implicits are worth the mental burden.
"scala/Option.option2Iterable"
"scala/Predef.any2stringadd"
# I don't understand why these are synthetic
# https://github.com/scalacenter/scalafix/issues/703
{
regex = {
includes = [
"^\\Qscala/collection/MapLike#apply().\\E$"
"^\\Qscala/collection/LinearSeqOptimized#apply().\\E$"
]
}
message = "not a total function"
}
]
Disable.unlessInside = [
{
safeBlocks = [
"fommil/std/IO"
"scalaz/ioeffect/IO"
"scalaz/ioeffect/Task"
"scalaz/ApplicativeError.handleError"
"scalaz/ApplicativeError.raiseError"
"scalaz/syntax/ApplicativeErrorOps.handleError"
"scalaz/syntax/ApplicativeErrorOps.recover"
"scalaz/syntax/MonadErrorOps.emap"
"scalaz/zio/IO"
"scalaz/zio/Task"
"scalaz/zio/UIO"
"scalaz/zio/ZIO"
"scalaz/zio/ZIO_E_Throwable.effect"
"scalaz/zio/ZIOFunctions.effectAsync"
"scalaz/zio/ZIOFunctions.effectTotal"
"scalaz/zio/ZIOFunctions.effectTotalWith"
"scalaz/zio/ZIOFunctions.fail"
"scalaz/zio/ZIOFunctions.halt"
]
symbols = [
{
# This takes the approach of banning everything and then blessing things
# we trust. It would be entirely feasible to do it the other way and
# list the explicit list of things that we need to go through IO, but it
# is less safe. We can have another rule if something in an "excludes"
# glob catches unsafe things.
#
# If something is referentially transparent but not total, instead of
# adding to this excludes list, add it to the includes list of the
# scalaz.Maybe.attempt safeBlock. If it can return `null`, add it to a
# scalaz.Maybe.fromNullable safeBlock.
regex = {
includes = [
"^\\Qjava/\\E.*$"
#"^.*$"
]
excludes = [
"^fommil.*$"
"^scalaz.*$"
"^\\Qjava/lang/String#\\E.*$"
"^\\Qjava/time/Instant#\\E.*$"
"^\\Qjava/time/ZonedDateTime#\\E.*$"
"^\\Qjava/time/temporal/ChronoUnit#\\E.*$"
"^\\Qjava/net/URI#\\E.*$"
"^\\Qjava/net/URLEncoder#\\E.*$"
"^\\Qjava/net/URLDecoder#\\E.*$"
# primitives are not supported: https://github.com/scalameta/scalameta/issues/1488
# WORKAROUND https://github.com/scalacenter/scalafix/issues/715
"^\\Qjava/\\E$"
"^\\Qjava/lang/\\E$"
"^\\Qjava/time/\\E$"
"^\\Qjava/net\\E$"
]
}
message = "Untrusted third party library must be called from IO, or blessed in scalafix.conf"
}
]
}
{
safeBlocks = [
"scalaz/`\/`.fromTryCatchNonFatal",
"scalaz/`\/`.fromTryCatchThrowable",
"scalaz/Maybe.attempt",
"scalaz/Maybe.fromTryCatchNonFatal",
"scalaz/Maybe.fromTryCatchThrowable"
]
symbols = [
{
regex = {
includes = [
# should live in a common file so we don't need to duplicate
"^\\Qjava/net/URLEncoder#\\E.*$"
"^\\Qjava/net/URLDecoder#\\E.*$"
]
excludes = [
]
}
message = "Deterministic method is not total, must be called via Maybe.attempt, \/.fromTryCatchNonFatal, etc."
}
]
}
]
DisableSyntax {
noAsInstanceOf = true
noContravariantTypes = true
noCovariantTypes = true
noDefaultArgs = true
noFinalVal = true
noFinalize = true
noImplicitConversion = true
noImplicitObject = true
noIsInstanceOf = true
noNulls = true
noReturns = true
noSemicolons = true
noTabs = true
noThrows = true
noUniversalEquality = true
noValInAbstract = true
noValPatterns = true
noVars = true
noWhileLoops = true
noXml = true
}
ExplicitResultTypes {
unsafeShortenNames = true
fatalWarnings = true
# these apply to non-implicits
memberKind = [Def, Val]
memberVisibility = [Public, Protected]
# turn to the max...
skipSimpleDefinitions = false
skipLocalImplicits = false
}