Skip to content

Commit

Permalink
Fix some rubocop warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ohler55 committed Jul 25, 2023
1 parent 5849242 commit 2ffe617
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ Style/NumericPredicate:
Style/HashSyntax:
Enabled: false

Style/TernaryParentheses:
Enabled: false

Layout/ExtraSpacing:
AllowForAlignment: true,
AllowBeforeTrailingComments: true
Expand Down
8 changes: 5 additions & 3 deletions ext/oj/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'mkmf'
require 'rbconfig'

Expand All @@ -6,7 +8,7 @@

parts = RUBY_DESCRIPTION.split(' ')
type = parts[0]
type = type[4..-1] if type.start_with?('tcs-')
type = type[4..] if type.start_with?('tcs-')
is_windows = RbConfig::CONFIG['host_os'] =~ /(mingw|mswin)/
platform = RUBY_PLATFORM
version = RUBY_VERSION.split('.')
Expand Down Expand Up @@ -56,7 +58,7 @@
end

$CPPFLAGS += ' -Wall'
#puts "*** $CPPFLAGS: #{$CPPFLAGS}"
# puts "*** $CPPFLAGS: #{$CPPFLAGS}"
# Adding the __attribute__ flag only works with gcc compilers and even then it
# does not work to check args with varargs so just remove the check.
CONFIG['warnflags'].slice!(/ -Wsuggest-attribute=format/)
Expand All @@ -65,4 +67,4 @@

create_makefile(File.join(extension_name, extension_name))

%x{make clean}
`{make clean}`
5 changes: 2 additions & 3 deletions lib/oj/active_support_helper.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# frozen_string_literal: true

require 'active_support/time'

module Oj

# Exists only to handle the ActiveSupport::TimeWithZone.
class ActiveSupportHelper

def self.createTimeWithZone(utc, zone)
ActiveSupport::TimeWithZone.new(utc - utc.gmt_offset, ActiveSupport::TimeZone[zone])
end
end

end

Oj.register_odd(ActiveSupport::TimeWithZone, Oj::ActiveSupportHelper, :createTimeWithZone, :utc, 'time_zone.name')
Expand Down
1 change: 1 addition & 0 deletions lib/oj/json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def parse()
begin
send(:remove_const, :Parser)
rescue
# ignore and move on
end
Parser = ::JSON::Ext::Parser unless defined?(::JSON::Parser)
self.parser = ::JSON::Ext::Parser
Expand Down
4 changes: 3 additions & 1 deletion lib/oj/mimic.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'bigdecimal'
begin
require 'ostruct'
Expand Down Expand Up @@ -266,7 +268,7 @@ def as_json(*)
end
end
def self.json_create(h)
if usec = h.delete('u')
if (usec = h.delete('u'))
h['n'] = usec * 1000
end
if instance_methods.include?(:tv_nsec)
Expand Down

0 comments on commit 2ffe617

Please sign in to comment.