From 3ab21c9616394834a94d2003623c4cbc845faff0 Mon Sep 17 00:00:00 2001 From: Sorcus Date: Tue, 29 Sep 2020 21:53:34 +0000 Subject: [PATCH] Fix typos and remove redundant use of 'Object#to_s' --- spec/cbor/encoder_spec.cr | 2 +- spec/cbor/lexer_spec.cr | 2 +- spec/cbor/to_cbor_spec.cr | 2 +- src/cbor/diagnostic.cr | 4 ++-- src/cbor/encoder.cr | 2 +- src/cbor/from_cbor.cr | 4 ++-- src/cbor/lexer.cr | 4 ++-- src/cbor/serializable.cr | 2 +- src/cbor/simple_value.cr | 2 +- src/cbor/to_cbor.cr | 4 ++-- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/spec/cbor/encoder_spec.cr b/spec/cbor/encoder_spec.cr index c7e5dca..b79caea 100644 --- a/spec/cbor/encoder_spec.cr +++ b/spec/cbor/encoder_spec.cr @@ -71,7 +71,7 @@ describe CBOR::Encoder do bytes_arr = hex_string.split.map(&.to_u8(16)) want_bytes = Bytes.new(bytes_arr.to_unsafe, bytes_arr.size) - it "econdes #{value.to_s} to #{want_bytes.hexstring}" do + it "encodes #{value} to #{want_bytes.hexstring}" do res = IO::Memory.new encoder = CBOR::Encoder.new(res) diff --git a/spec/cbor/lexer_spec.cr b/spec/cbor/lexer_spec.cr index 007bbea..db1300f 100644 --- a/spec/cbor/lexer_spec.cr +++ b/spec/cbor/lexer_spec.cr @@ -21,7 +21,7 @@ describe CBOR::Lexer do ] tests.each do |tt| - it "reads #{tt[:bytes].hexstring} as #{tt[:value].to_s}" do + it "reads #{tt[:bytes].hexstring} as #{tt[:value]}" do lexer = CBOR::Lexer.new(tt[:bytes]) token = lexer.next_token diff --git a/spec/cbor/to_cbor_spec.cr b/spec/cbor/to_cbor_spec.cr index 36d32ca..9e419a9 100644 --- a/spec/cbor/to_cbor_spec.cr +++ b/spec/cbor/to_cbor_spec.cr @@ -41,7 +41,7 @@ describe "to_cbor" do tests.each do |tt| type, bytes, value = tt - it "encodes #{value.inspect} of type #{type.to_s}" do + it "encodes #{value.inspect} of type #{type}" do res = value.to_cbor res.hexdump.should eq(bytes.hexdump) end diff --git a/src/cbor/diagnostic.cr b/src/cbor/diagnostic.cr index 0233992..6aedaa3 100644 --- a/src/cbor/diagnostic.cr +++ b/src/cbor/diagnostic.cr @@ -1,5 +1,5 @@ # Reads a CBOR input into a diagnostic string. -# This consumes the IO and is mostly usedful to tests again the example +# This consumes the IO and is mostly useful to tests again the example # provided in the RFC and ensuring a correct functioning of the `CBOR::Lexer`. class CBOR::Diagnostic @lexer : Lexer @@ -63,7 +63,7 @@ class CBOR::Diagnostic when Tag::NegativeBigNum read_big_int(negative: true) else - "#{token.value.value.to_s}(#{next_value})" + "#{token.value.value}(#{next_value})" end when Token::FloatT return "NaN" if token.value.nan? diff --git a/src/cbor/encoder.cr b/src/cbor/encoder.cr index aaca8de..65e5e63 100644 --- a/src/cbor/encoder.cr +++ b/src/cbor/encoder.cr @@ -48,7 +48,7 @@ class CBOR::Encoder return write(value.to_u64) if value >= 0 # When it's negative, transform it into a positive value and write the - # resulting unsigled int with an offset + # resulting unsigned int with an offset positive_value = -(value + 1) write(positive_value.to_u64, 0x20) end diff --git a/src/cbor/from_cbor.cr b/src/cbor/from_cbor.cr index 72a09b8..e2610e7 100644 --- a/src/cbor/from_cbor.cr +++ b/src/cbor/from_cbor.cr @@ -180,7 +180,7 @@ def BigInt.new(decoder : CBOR::Decoder) end # Reads the CBOR value as a BigDecimal. -# If the next token is a flaot, then it'll be transformed to a BigDecimal, +# If the next token is a float, then it'll be transformed to a BigDecimal, # otherwhise the value must be correctly tagged with value 4 (decimal fraction) # or 5 (big float). def BigDecimal.new(decoder : CBOR::Decoder) @@ -231,7 +231,7 @@ def Union.new(decoder : CBOR::Decoder) return {{type}}.new(decoder) {% end %} else - # This case check is non-exaustive on purpose + # This case check is non-exhaustive on purpose end {% end %} diff --git a/src/cbor/lexer.cr b/src/cbor/lexer.cr index ac58d5e..8ba2a11 100644 --- a/src/cbor/lexer.cr +++ b/src/cbor/lexer.cr @@ -164,7 +164,7 @@ class CBOR::Lexer end private def consume_simple_value(id) : Token::SimpleValueT - raise ParseError.new("Invalid simple value #{id.to_s}") if id > 255 + raise ParseError.new("Invalid simple value #{id}") if id > 255 Token::SimpleValueT.new(value: SimpleValue.new(id.to_u8)) end @@ -176,7 +176,7 @@ class CBOR::Lexer {% conv = %w(to_i8 to_i16 to_i32 to_i64 to_i128) %} {% for uint, index in uints %} - # Reads the `{{uint.id}}` as a negative integer, returning the samllest + # Reads the `{{uint.id}}` as a negative integer, returning the smallest # integer capable of containing the value. def to_negative_int(value : {{uint.id}}) int = begin diff --git a/src/cbor/serializable.cr b/src/cbor/serializable.cr index 7d2fcd1..7ebd7d2 100644 --- a/src/cbor/serializable.cr +++ b/src/cbor/serializable.cr @@ -143,7 +143,7 @@ module CBOR end # When the type is inherited, carry over the `new` - # so it can compete with other possible intializes + # so it can compete with other possible initializes macro inherited def self.new(decoder : ::CBOR::Decoder) diff --git a/src/cbor/simple_value.cr b/src/cbor/simple_value.cr index fb104ba..483a23e 100644 --- a/src/cbor/simple_value.cr +++ b/src/cbor/simple_value.cr @@ -15,7 +15,7 @@ enum CBOR::SimpleValue : UInt8 when Undefined "undefined" else - "simple(#{self.value.to_s})" + "simple(#{self.value})" end end diff --git a/src/cbor/to_cbor.cr b/src/cbor/to_cbor.cr index 0688478..dedd90b 100644 --- a/src/cbor/to_cbor.cr +++ b/src/cbor/to_cbor.cr @@ -79,7 +79,7 @@ module Time::Format::RFC_3339 end module Time::EpochConverter - # Emits the time as a tagged unix timestamp, asp specified by + # Emits the time as a tagged unix timestamp, as specified by # [RFC 7049 section 2.4.1](https://tools.ietf.org/html/rfc7049#section-2.4.1). # def self.to_cbor(value : Time, encoder : CBOR::Encoder) @@ -108,7 +108,7 @@ struct Time end # struct BigInt -# # Encodes the value a bytes arrya tagged with the CBOR tag 2 or 3, as specified +# # Encodes the value a bytes array tagged with the CBOR tag 2 or 3, as specified # # in [RFC 7049 Section 2.4.2](https://tools.ietf.org/html/rfc7049#section-2.4.2). # def to_cbor(encoder : CBOR::Encoder) # encoded_value = BigInt.new(self)