Skip to content

Commit

Permalink
Update to RuboCop 0.51
Browse files Browse the repository at this point in the history
  • Loading branch information
tarcieri committed Nov 21, 2017
1 parent 699e329 commit 1e638bc
Show file tree
Hide file tree
Showing 27 changed files with 53 additions and 50 deletions.
3 changes: 1 addition & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
AllCops:
TargetRubyVersion: 2.4
DisplayCopNames: true
Include:
- '**/Rakefile'
Exclude:
- 'spec/**/*'
- 'vendor/**/*'
Expand Down
1 change: 0 additions & 1 deletion .ruby-version

This file was deleted.

6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source "https://rubygems.org"

gemspec
Expand All @@ -7,10 +9,10 @@ group :development do
end

group :test do
gem "rspec"
gem "rubocop", "0.46.0"
gem "coveralls", require: false
gem "rbnacl-libsodium", ENV["LIBSODIUM_VERSION"]
gem "rspec"
gem "rubocop", "0.51.0"
end

group :development, :test do
Expand Down
2 changes: 2 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# A sample Guardfile
# More info at https://github.com/guard/guard#readme

Expand Down
5 changes: 3 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# frozen_string_literal: true

require "bundler/gem_tasks"

Dir[File.expand_path("../tasks/**/*.rake", __FILE__)].each { |task| load task }

task default: %w(spec rubocop)
task ci: %w(spec rubocop)
task default: %w[spec rubocop]
task ci: %w[spec rubocop]
4 changes: 2 additions & 2 deletions lib/rbnacl/aead/chacha20poly1305_ietf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class ChaCha20Poly1305IETF < RbNaCl::AEAD::Base

sodium_function :aead_chacha20poly1305_ietf_encrypt,
:crypto_aead_chacha20poly1305_ietf_encrypt,
[:pointer, :pointer, :pointer, :ulong_long, :pointer, :ulong_long, :pointer, :pointer, :pointer]
%i[pointer pointer pointer ulong_long pointer ulong_long pointer pointer pointer]

sodium_function :aead_chacha20poly1305_ietf_decrypt,
:crypto_aead_chacha20poly1305_ietf_decrypt,
[:pointer, :pointer, :pointer, :pointer, :ulong_long, :pointer, :ulong_long, :pointer, :pointer]
%i[pointer pointer pointer pointer ulong_long pointer ulong_long pointer pointer]

private

Expand Down
4 changes: 2 additions & 2 deletions lib/rbnacl/aead/chacha20poly1305_legacy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class ChaCha20Poly1305Legacy < RbNaCl::AEAD::Base

sodium_function :aead_chacha20poly1305_encrypt,
:crypto_aead_chacha20poly1305_encrypt,
[:pointer, :pointer, :pointer, :ulong_long, :pointer, :ulong_long, :pointer, :pointer, :pointer]
%i[pointer pointer pointer ulong_long pointer ulong_long pointer pointer pointer]

sodium_function :aead_chacha20poly1305_decrypt,
:crypto_aead_chacha20poly1305_decrypt,
[:pointer, :pointer, :pointer, :pointer, :ulong_long, :pointer, :ulong_long, :pointer, :pointer]
%i[pointer pointer pointer pointer ulong_long pointer ulong_long pointer pointer]

private

Expand Down
6 changes: 3 additions & 3 deletions lib/rbnacl/boxes/curve25519xsalsa20poly1305.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ class Curve25519XSalsa20Poly1305

sodium_function :box_curve25519xsalsa20poly1305_beforenm,
:crypto_box_curve25519xsalsa20poly1305_beforenm,
[:pointer, :pointer, :pointer]
%i[pointer pointer pointer]

sodium_function :box_curve25519xsalsa20poly1305_open_afternm,
:crypto_box_curve25519xsalsa20poly1305_open_afternm,
[:pointer, :pointer, :ulong_long, :pointer, :pointer]
%i[pointer pointer ulong_long pointer pointer]

sodium_function :box_curve25519xsalsa20poly1305_afternm,
:crypto_box_curve25519xsalsa20poly1305_afternm,
[:pointer, :pointer, :ulong_long, :pointer, :pointer]
%i[pointer pointer ulong_long pointer pointer]

# Create a new Box
#
Expand Down
2 changes: 1 addition & 1 deletion lib/rbnacl/boxes/curve25519xsalsa20poly1305/private_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class PrivateKey

sodium_function :box_curve25519xsalsa20poly1305_keypair,
:crypto_box_curve25519xsalsa20poly1305_keypair,
[:pointer, :pointer]
%i[pointer pointer]

# The size of the key, in bytes
BYTES = Boxes::Curve25519XSalsa20Poly1305::PRIVATEKEYBYTES
Expand Down
2 changes: 1 addition & 1 deletion lib/rbnacl/group_elements/curve25519.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Curve25519

sodium_function :scalarmult_curve25519,
:crypto_scalarmult_curve25519,
[:pointer, :pointer, :pointer]
%i[pointer pointer pointer]

# Number of bytes in a scalar on this curve
SCALARBYTES = 32
Expand Down
8 changes: 4 additions & 4 deletions lib/rbnacl/hash/blake2b.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ class Blake2b

sodium_function :generichash_blake2b,
:crypto_generichash_blake2b_salt_personal,
[:pointer, :size_t, :pointer, :ulong_long, :pointer, :size_t, :pointer, :pointer]
%i[pointer size_t pointer ulong_long pointer size_t pointer pointer]

sodium_function :generichash_blake2b_init,
:crypto_generichash_blake2b_init_salt_personal,
[:pointer, :pointer, :size_t, :size_t, :pointer, :pointer]
%i[pointer pointer size_t size_t pointer pointer]

sodium_function :generichash_blake2b_update,
:crypto_generichash_blake2b_update,
[:pointer, :pointer, :ulong_long]
%i[pointer pointer ulong_long]

sodium_function :generichash_blake2b_final,
:crypto_generichash_blake2b_final,
[:pointer, :pointer, :size_t]
%i[pointer pointer size_t]

EMPTY_PERSONAL = ("\0" * PERSONALBYTES).freeze
EMPTY_SALT = ("\0" * SALTBYTES).freeze
Expand Down
2 changes: 1 addition & 1 deletion lib/rbnacl/hash/sha256.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module SHA256
sodium_constant :BYTES
sodium_function :hash_sha256,
:crypto_hash_sha256,
[:pointer, :pointer, :ulong_long]
%i[pointer pointer ulong_long]
end
end
end
2 changes: 1 addition & 1 deletion lib/rbnacl/hash/sha512.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module SHA512
sodium_constant :BYTES
sodium_function :hash_sha512,
:crypto_hash_sha512,
[:pointer, :pointer, :ulong_long]
%i[pointer pointer ulong_long]
end
end
end
4 changes: 2 additions & 2 deletions lib/rbnacl/hmac/sha256.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class SHA256 < Auth

sodium_function :auth_hmacsha256,
:crypto_auth_hmacsha256,
[:pointer, :pointer, :ulong_long, :pointer]
%i[pointer pointer ulong_long pointer]

sodium_function :auth_hmacsha256_verify,
:crypto_auth_hmacsha256_verify,
[:pointer, :pointer, :ulong_long, :pointer]
%i[pointer pointer ulong_long pointer]

private

Expand Down
4 changes: 2 additions & 2 deletions lib/rbnacl/hmac/sha512.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class SHA512 < Auth

sodium_function :auth_hmacsha512,
:crypto_auth_hmacsha512,
[:pointer, :pointer, :ulong_long, :pointer]
%i[pointer pointer ulong_long pointer]

sodium_function :auth_hmacsha512_verify,
:crypto_auth_hmacsha512_verify,
[:pointer, :pointer, :ulong_long, :pointer]
%i[pointer pointer ulong_long pointer]

private

Expand Down
4 changes: 2 additions & 2 deletions lib/rbnacl/hmac/sha512256.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class SHA512256 < Auth

sodium_function :auth_hmacsha512256,
:crypto_auth_hmacsha512256,
[:pointer, :pointer, :ulong_long, :pointer]
%i[pointer pointer ulong_long pointer]

sodium_function :auth_hmacsha512256_verify,
:crypto_auth_hmacsha512256_verify,
[:pointer, :pointer, :ulong_long, :pointer]
%i[pointer pointer ulong_long pointer]

private

Expand Down
4 changes: 2 additions & 2 deletions lib/rbnacl/one_time_auths/poly1305.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ class Poly1305 < Auth

sodium_function :onetimeauth_poly1305,
:crypto_onetimeauth_poly1305,
[:pointer, :pointer, :ulong_long, :pointer]
%i[pointer pointer ulong_long pointer]

sodium_function :onetimeauth_poly1305_verify,
:crypto_onetimeauth_poly1305_verify,
[:pointer, :pointer, :ulong_long, :pointer]
%i[pointer pointer ulong_long pointer]

private

Expand Down
6 changes: 3 additions & 3 deletions lib/rbnacl/password_hash/argon2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ class Argon2
sodium_function_with_return_code(
:pwhash,
:crypto_pwhash_argon2i,
[:pointer, :ulong_long, :pointer, :ulong_long, :pointer, :ulong_long, :size_t, :int]
%i[pointer ulong_long pointer ulong_long pointer ulong_long size_t int]
)

sodium_function(
:pwhash_str,
:crypto_pwhash_argon2i_str,
[:pointer, :pointer, :ulong_long, :ulong_long, :size_t]
%i[pointer pointer ulong_long ulong_long size_t]
)

sodium_function(
:pwhash_str_verify,
:crypto_pwhash_argon2i_str_verify,
[:pointer, :pointer, :ulong_long]
%i[pointer pointer ulong_long]
)

ALG_DEFAULT = ALG_ARGON2I13
Expand Down
2 changes: 1 addition & 1 deletion lib/rbnacl/password_hash/scrypt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SCrypt

sodium_function :scrypt,
:crypto_pwhash_scryptsalsa208sha256,
[:pointer, :ulong_long, :pointer, :ulong_long, :pointer, :ulong_long, :size_t]
%i[pointer ulong_long pointer ulong_long pointer ulong_long size_t]

# Create a new SCrypt password hash object
#
Expand Down
4 changes: 1 addition & 3 deletions lib/rbnacl/random.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# encoding: binary
# frozen_string_literal: true

require "thread"

module RbNaCl
# Functions for random number generation
#
Expand All @@ -15,7 +13,7 @@ module Random

sodium_function :c_random_bytes,
:randombytes_buf,
[:pointer, :ulong_long]
%i[pointer ulong_long]

# Returns a string of random bytes
#
Expand Down
4 changes: 2 additions & 2 deletions lib/rbnacl/secret_boxes/xsalsa20poly1305.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class XSalsa20Poly1305

sodium_function :secretbox_xsalsa20poly1305,
:crypto_secretbox_xsalsa20poly1305,
[:pointer, :pointer, :ulong_long, :pointer, :pointer]
%i[pointer pointer ulong_long pointer pointer]

sodium_function :secretbox_xsalsa20poly1305_open,
:crypto_secretbox_xsalsa20poly1305_open,
[:pointer, :pointer, :ulong_long, :pointer, :pointer]
%i[pointer pointer ulong_long pointer pointer]

# Create a new SecretBox
#
Expand Down
4 changes: 2 additions & 2 deletions lib/rbnacl/signatures/ed25519/signing_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ class SigningKey

sodium_function :sign_ed25519,
:crypto_sign_ed25519,
[:pointer, :pointer, :pointer, :ulong_long, :pointer]
%i[pointer pointer pointer ulong_long pointer]

sodium_function :sign_ed25519_seed_keypair,
:crypto_sign_ed25519_seed_keypair,
[:pointer, :pointer, :pointer]
%i[pointer pointer pointer]

attr_reader :verify_key

Expand Down
2 changes: 1 addition & 1 deletion lib/rbnacl/signatures/ed25519/verify_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class VerifyKey

sodium_function :sign_ed25519_open,
:crypto_sign_ed25519_open,
[:pointer, :pointer, :pointer, :ulong_long, :pointer]
%i[pointer pointer pointer ulong_long pointer]

# Create a new VerifyKey object from a public key.
#
Expand Down
8 changes: 4 additions & 4 deletions lib/rbnacl/sodium.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ def sodium_constant(constant, name = constant)
end

def sodium_function(name, function, arguments)
module_eval <<-eos, __FILE__, __LINE__ + 1
module_eval <<-RUBY, __FILE__, __LINE__ + 1
attach_function #{function.inspect}, #{arguments.inspect}, :int
def self.#{name}(*args)
ret = #{function}(*args)
ret == 0
end
eos
RUBY
end

def sodium_function_with_return_code(name, function, arguments)
module_eval <<-eos, __FILE__, __LINE__ + 1
module_eval <<-RUBY, __FILE__, __LINE__ + 1
attach_function #{function.inspect}, #{arguments.inspect}, :int
def self.#{name}(*args)
#{function}(*args)
end
eos
RUBY
end
end
end
2 changes: 1 addition & 1 deletion lib/rbnacl/sodium/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module Version
raise "Sorry, you need to install libsodium #{MINIMUM_LIBSODIUM_VERSION}+. You have #{Version::STRING} installed"
end

ARGON2_SUPPORTED = (INSTALLED_VERSION <=> MINIMUM_LIBSODIUM_VERSION_FOR_ARGON2) == -1 ? false : true
ARGON2_SUPPORTED = (INSTALLED_VERSION <=> MINIMUM_LIBSODIUM_VERSION_FOR_ARGON2) != -1

# Determine if a given feature is supported based on Sodium version
def self.supported_version?(version)
Expand Down
4 changes: 2 additions & 2 deletions lib/rbnacl/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ module RbNaCl
module Util
extend Sodium

sodium_function :c_verify16, :crypto_verify_16, [:pointer, :pointer]
sodium_function :c_verify32, :crypto_verify_32, [:pointer, :pointer]
sodium_function :c_verify16, :crypto_verify_16, %i[pointer pointer]
sodium_function :c_verify32, :crypto_verify_32, %i[pointer pointer]

module_function

Expand Down
4 changes: 3 additions & 1 deletion rbnacl.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- encoding: utf-8 -*-

# frozen_string_literal: true

lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "rbnacl/version"
Expand Down

0 comments on commit 1e638bc

Please sign in to comment.