0
を働いていないようです:CodeNarcを抑圧JdbcREsultSetReferenceは、私はこれと同じクラスを持つ
import org.springframework.jdbc.core.RowMapper
import java.sql.ResultSet
class DataMapper implements RowMapper<Data> {
@Override
@SupressWarnings('JdbcResultSetReference')
Data mapRow(ResultSet resultSet, int rowNum) throws SQLException {
// get some values from resultSet and return desired Data
}
}
これは、グルーヴィーを使用して、いくつかのデータを移行する1時間のスクリプトですので、私はcodenarcルールを抑制します。 ruleSet
では、jdbcのルールが含まれており、すべてのプロジェクトをスキャンするので、それらのルールを無効にしたくありません。
<ruleset xmlns="http://codenarc.org/ruleset/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://codenarc.org/ruleset/1.0
http://codenarc.org/ruleset-schema.xsd"
xsi:noNamespaceSchemaLocation="http://codenarc.org/ruleset-schema.xsd">
<description>Static analysis rule set for Groovy sources</description>
<!-- not related rules -->
<ruleset-ref path='rulesets/jdbc.xml>
</ruleset>
私は、JUnitテスト内の静的解析を実行すると、このエラーを取得しています:
[codenarc] File: com/example/migrate/DataMapper.groovy [codenarc] Violation: Rule=JdbcResultSetReference P=2 Line=5 Msg=[Found reference to java.sql.ResultSet] Src=[import java.sql.ResultSet] [codenarc] Violation: Rule=JdbcResultSetReference P=2 Line=5 Msg=[Found reference to java.sql.ResultSet] Src=[import java.sql.ResultSet] [codenarc] [CodeNarc (http://www.codenarc.org) v1.0] [codenarc] CodeNarc completed: (p1=0; p2=2; p3=0) 5929ms
私はクラスに@SupressWarnings
を移動しようとしたが、それはまだ私がルールに違反してると言われます。それで問題は、その抑圧をどのように働かせるかです。