You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Provide several examples of what would and wouldn't trigger violations.
Would trigger
// UITableView alternating row colour
cell.contentView.backgroundColor = indexPath.row %2==0?.gray : .white
// Codable.swift.gyb in apple/swift
guard count %2==0else{throwDecodingError.dataCorrupted(...)}
// Bool.swift in apple/swift
publicstaticfunc random<T:RandomNumberGenerator>(using generator:inoutT)->Bool{return(generator.next() >> 17)&1==0}
// KeyPath.swift in apple/swift
_sanityCheck(bytes >0 && bytes %4==0,"capacity must be multiple of 4 bytes")
// ReversedCollection Index.base documentation https://developer.apple.com/documentation/swift/reversedcollection/index/2965437-base
guard let i = reversedNumbers.firstIndex(where:{ $0 %2==0})
Wouldn't trigger
// UITableView alternating row colour
cell.contentView.backgroundColor = indexPath.row.isMultiple(of:2)?.gray : .white
// Codable.swift.gyb in apple/swift
guard count.isMultiple(of:2)else{throwDecodingError.dataCorrupted(...)}
// Bool.swift in apple/swift
publicstaticfunc random<T:RandomNumberGenerator>(using generator:inoutT)->Bool{return(generator.next() >> 17).isMultiple(of:2)}
// KeyPath.swift in apple/swift
_sanityCheck(bytes >0 && bytes.isMultiple(of:4),"capacity must be multiple of 4 bytes")
// not used in a boolean context
letsecretValue=(value %3)+2
Should the rule be configurable, if so what parameters should be configurable?
Just severity
Should the rule be opt-in or enabled by default? Why?
See README.md for guidelines on when to mark a rule as opt-in.
Opt-in as isMultiple(of:) is only available on Swift 5+.
The text was updated successfully, but these errors were encountered:
New Issue Checklist
New rule request
Prefer using
x.isMultiple(of: y)
thanx % y == 0
.the community thinks about this.
https://github.com/apple/swift-evolution/blob/master/proposals/0225-binaryinteger-iseven-isodd-ismultiple.md
Would trigger
Wouldn't trigger
Just severity
See README.md for guidelines on when to mark a rule as opt-in.
Opt-in as
isMultiple(of:)
is only available on Swift 5+.The text was updated successfully, but these errors were encountered: