Skip to content

Commit 54f2ebf

Browse files
committed
Add jt spotbugs and mx ruby_spotbugs to run more SpotBugs checks
1 parent df5a630 commit 54f2ebf

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

mx.truffleruby/mx_truffleruby.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import mx
1414
import mx_sdk
1515
import mx_subst
16+
import mx_spotbugs
1617

1718
if 'RUBY_BENCHMARKS' in os.environ:
1819
import mx_truffleruby_benchmark # pylint: disable=unused-import
@@ -160,6 +161,14 @@ def ruby_testdownstream_sulong(args):
160161
jt('test', 'mri', '--all-sulong')
161162
jt('test', 'cexts')
162163

164+
def ruby_spotbugs(args):
165+
"""Run SpotBugs with custom options to detect more issues"""
166+
filters = join(root, 'mx.truffleruby', 'spotbugs-filters.xml')
167+
spotbugsArgs = ['-textui', '-low', '-longBugCodes', '-include', filters]
168+
if mx.is_interactive():
169+
spotbugsArgs.append('-progress')
170+
mx_spotbugs.spotbugs(args, spotbugsArgs)
171+
163172
def verify_ci(args):
164173
"""Verify CI configuration"""
165174
mx.verify_ci(args, mx.suite('truffle'), _suite, 'common.json')
@@ -247,5 +256,6 @@ def verify_ci(args):
247256
'ruby_testdownstream_aot': [ruby_testdownstream_aot, 'aot_bin'],
248257
'ruby_testdownstream_hello': [ruby_testdownstream_hello, ''],
249258
'ruby_testdownstream_sulong': [ruby_testdownstream_sulong, ''],
259+
'ruby_spotbugs': [ruby_spotbugs, ''],
250260
'verify-ci' : [verify_ci, '[options]'],
251261
})

mx.truffleruby/spotbugs-filters.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<FindBugsFilter>
3+
<Match>
4+
<Package name="~org\.truffleruby.*" />
5+
<Not>
6+
<Or>
7+
<!-- These are not worth fixing -->
8+
<Bug pattern="MS_PKGPROTECT" />
9+
<Bug pattern="MS_MUTABLE_ARRAY" />
10+
<Bug pattern="MS_MUTABLE_COLLECTION" />
11+
<Bug pattern="SF_SWITCH_NO_DEFAULT" />
12+
<Bug pattern="RI_REDUNDANT_INTERFACES" />
13+
<!-- Intentional -->
14+
<Bug pattern="BC_UNCONFIRMED_CAST" />
15+
<Bug pattern="BC_UNCONFIRMED_CAST_OF_RETURN_VALUE" />
16+
<Bug pattern="DM_EXIT" />
17+
<Bug pattern="DM_GC" />
18+
<Bug pattern="EI_EXPOSE_REP" />
19+
<Bug pattern="EI_EXPOSE_REP2" />
20+
<Bug pattern="FE_FLOATING_POINT_EQUALITY" />
21+
</Or>
22+
</Not>
23+
</Match>
24+
</FindBugsFilter>

tool/jt.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2271,6 +2271,10 @@ def checkstyle
22712271
end
22722272
end
22732273

2274+
def spotbugs
2275+
mx 'ruby_spotbugs'
2276+
end
2277+
22742278
module Formatting
22752279
extend self
22762280

@@ -2466,7 +2470,7 @@ def lint(*args)
24662470
# TODO (pitr-ch 11-Aug-2019): consider running all tasks in the `mx gate --tags fullbuild`
24672471
# - includes verifylibraryurls though
24682472
# - building with jdt in the ci definition could be dropped since fullbuild builds with JDT
2469-
mx 'spotbugs' unless fast
2473+
spotbugs unless fast
24702474

24712475
mx 'verify-ci' if changed['.py']
24722476

0 commit comments

Comments
 (0)