Skip to content

Commit

Permalink
Update target ruby version for RuboCop and autocorrect new offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
mvz committed Oct 2, 2021
1 parent eec0554 commit 56073ff
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
Expand Up @@ -21,7 +21,7 @@ AllCops:
- 'db/schema.rb'
- 'vendor/bundle/**/*'
NewCops: enable
TargetRubyVersion: 2.4
TargetRubyVersion: 2.5

Rails:
Enabled: true
Expand Down
2 changes: 1 addition & 1 deletion publify_amazon_sidebar/.rubocop.yml
Expand Up @@ -9,7 +9,7 @@ AllCops:
- 'spec/dummy/bin/*'
- 'spec/dummy/db/schema.rb'
NewCops: enable
TargetRubyVersion: 2.4
TargetRubyVersion: 2.5

Rails:
Enabled: true
Expand Down
2 changes: 1 addition & 1 deletion publify_core/.rubocop.yml
Expand Up @@ -9,7 +9,7 @@ AllCops:
- 'spec/dummy/bin/*'
- 'spec/dummy/db/schema.rb'
NewCops: enable
TargetRubyVersion: 2.4
TargetRubyVersion: 2.5

Rails:
Enabled: true
Expand Down
16 changes: 7 additions & 9 deletions publify_core/lib/spam_protection.rb
Expand Up @@ -82,16 +82,14 @@ def scan_uris(uris = [])
def query_rbls(rbls, *subdomains)
rbls.each do |rbl|
subdomains.uniq.each do |d|
begin
response = IPSocket.getaddress([d, rbl].join("."))
if response.start_with?("127.0.0.")
throw :hit,
"#{rbl} positively resolved subdomain #{d} => #{response}"
end
rescue SocketError
# NXDOMAIN response => negative: d is not in RBL
next
response = IPSocket.getaddress([d, rbl].join("."))
if response.start_with?("127.0.0.")
throw :hit,
"#{rbl} positively resolved subdomain #{d} => #{response}"
end
rescue SocketError
# NXDOMAIN response => negative: d is not in RBL
next
end
end
false
Expand Down
36 changes: 16 additions & 20 deletions publify_core/spec/helpers/base_helper_spec.rb
Expand Up @@ -121,29 +121,25 @@ def parse_request(_contents, _request_params)
end

it "returns a link with the creation date and time" do
begin
timezone = Time.zone
Time.zone = "UTC"

expect(get_reply_context_twitter_link(reply)).
to eq '<a href="https://twitter.com/a_screen_name/status/123456789">' \
"23/01/2014 at 13h47</a>"
ensure
Time.zone = timezone
end
timezone = Time.zone
Time.zone = "UTC"

expect(get_reply_context_twitter_link(reply)).
to eq '<a href="https://twitter.com/a_screen_name/status/123456789">' \
"23/01/2014 at 13h47</a>"
ensure
Time.zone = timezone
end

it "displays creation date and time in the current time zone" do
begin
timezone = Time.zone
Time.zone = "Tokyo"

expect(get_reply_context_twitter_link(reply)).
to eq '<a href="https://twitter.com/a_screen_name/status/123456789">' \
"23/01/2014 at 22h47</a>"
ensure
Time.zone = timezone
end
timezone = Time.zone
Time.zone = "Tokyo"

expect(get_reply_context_twitter_link(reply)).
to eq '<a href="https://twitter.com/a_screen_name/status/123456789">' \
"23/01/2014 at 22h47</a>"
ensure
Time.zone = timezone
end
end

Expand Down
2 changes: 1 addition & 1 deletion publify_textfilter_code/.rubocop.yml
Expand Up @@ -9,7 +9,7 @@ AllCops:
- 'spec/dummy/bin/*'
- 'spec/dummy/db/schema.rb'
NewCops: enable
TargetRubyVersion: 2.4
TargetRubyVersion: 2.5

Rails:
Enabled: true
Expand Down
2 changes: 1 addition & 1 deletion publify_textfilter_code/lib/publify_app/textfilter_code.rb
Expand Up @@ -50,7 +50,7 @@ def self.macrofilter(attrib, text = "")
DEFAULT_OPTIONS
end

text = text.to_s.delete("\r").gsub(/\A\n/, "").chomp
text = text.to_s.delete("\r").delete_prefix("\n").chomp

begin
text = CodeRay.scan(text, lang.downcase.to_sym).span(options)
Expand Down

0 comments on commit 56073ff

Please sign in to comment.