Skip to content

Commit f167477

Browse files
committed
Fix some rubocop offenses
1 parent beea229 commit f167477

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

.rubocop.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
require:
1+
plugins:
22
- rubocop-performance
33
AllCops:
4-
TargetRubyVersion: '3.0'
4+
TargetRubyVersion: "3.0"
55
NewCops: enable
66
Exclude:
77
- .git/**/*
@@ -20,11 +20,11 @@ Lint/EmptyWhen:
2020
Lint/Void:
2121
Enabled: false
2222
Metrics/AbcSize:
23-
Max: 20
23+
Max: 20
2424
Metrics/ClassLength:
25-
Max: 200
25+
Max: 200
2626
Metrics/MethodLength:
27-
Max: 20
27+
Max: 20
2828
Metrics/ParameterLists:
2929
MaxOptionalParameters: 4
3030
Style/AccessModifierDeclarations:
@@ -46,7 +46,7 @@ Style/PerlBackrefs:
4646
Enabled: false
4747
Style/RaiseArgs:
4848
EnforcedStyle: exploded
49-
AllowedCompactTypes: ['ConstraintError', 'ChoiceError']
49+
AllowedCompactTypes: ["ConstraintError", "ChoiceError"]
5050
Style/RedundantSelf:
5151
Enabled: false
5252
Style/StructInheritance:

lib/rasn1.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module RASN1
2626
# @param [String] der binary string to parse
2727
# @param [Boolean] ber if +true+, decode a BER string, else a DER one
2828
# @return [Types::Base]
29-
def self.parse(der, ber: false) # rubocop:disable Metrics:AbcSize
29+
def self.parse(der, ber: false) # rubocop:disable Metrics/AbcSize
3030
type = Types.id2type(der)
3131
type.parse!(der, ber: ber)
3232

lib/rasn1/types/base.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def trace_data(data=nil)
359359
lines << str
360360
end
361361
str[compute_trace_index(byte_count, 3), 2] = '%02x' % byte
362-
str[compute_trace_index(byte_count, 1, 49)] = byte >= 32 && byte <= 126 ? byte.chr : '.'
362+
str[compute_trace_index(byte_count, 1, 49)] = byte.between?(32, 126) ? byte.chr : '.'
363363
byte_count += 1
364364
end
365365
lines.map(&:rstrip).join << "\n"
@@ -546,7 +546,11 @@ def encode_size(size)
546546
end
547547
end
548548

549-
def check_id(der)
549+
# Check ID from +der+ is the one expected
550+
# @return [Boolean] +true+ is ID is expected, +false+ if it is not but +self+ is {#optional?}
551+
# or has a {#default} value.
552+
# @raise [ASN1Error] ID was not expected, is not optional and has no default value
553+
def check_id(der) # rubocop:disable Naming/PredicateMethod
550554
expected_id = encode_identifier_octets
551555
real_id = der[0, expected_id.size]
552556
return true if real_id == expected_id

lib/rasn1/types/boolean.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Boolean < Primitive
1414
DER_FALSE = 0
1515

1616
# @return [false]
17-
def void_value
17+
def void_value # rubocop:disable Naming/PredicateMethod
1818
false
1919
end
2020

lib/rasn1/types/visible_string.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module RASN1
44
module Types
55
# Create VisibleString as a Constrained subclass of IA5String
66
Types.define_type(:VisibleString, from: IA5String) do |value|
7-
value.nil? || value.chars.all? { |c| c.ord >= 32 && c.ord <= 126 }
7+
value.nil? || value.chars.all? { |c| c.ord.between?(32, 126) }
88
end
99

1010
# ASN.1 Visible String

0 commit comments

Comments
 (0)