Skip to content
Permalink
Browse files

RuboCop: frozen string literals, comment whitespace (#1256)

* RuboCop: Style/FrozenStringLiteralComment, Layout/EmptyLineAfterMagicComment, Layout/LeadingCommentSpace
* Removed duplicated magic comments in Rack::RewindableInput
  • Loading branch information
yhirano55 authored and jeremy committed Apr 17, 2018
1 parent f1c4b0b commit b3d01dad952a371627afc14714a8c6896c3297b5
@@ -4,6 +4,18 @@ AllCops:
Exclude:
- '**/vendor/**/*'

Style/FrozenStringLiteralComment:
Enabled: true
EnforcedStyle: always

# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
Style/HashSyntax:
Enabled: true

Layout/EmptyLineAfterMagicComment:
Enabled: true

Layout/LeadingCommentSpace:
Enabled: true
Exclude:
- 'test/builder/options.ru'
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gemspec
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "rack"
Rack::Server.start
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rack/lobster'

use Rack::ShowExceptions
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rack/lobster'

use Rack::ShowExceptions
@@ -5,9 +5,9 @@

module Rack
### This middleware provides hooks to certain places in the request /
#response lifecycle. This is so that middleware that don't need to filter
#the response data can safely leave it alone and not have to send messages
#down the traditional "rack stack".
# response lifecycle. This is so that middleware that don't need to filter
# the response data can safely leave it alone and not have to send messages
# down the traditional "rack stack".
#
# The events are:
#
@@ -1,6 +1,6 @@
# -*- encoding: binary -*-
# frozen_string_literal: true

# -*- encoding: binary -*-
require 'tempfile'
require 'rack/utils'

@@ -1,7 +1,6 @@
# frozen_string_literal: true

# -*- encoding: binary -*-
# frozen_string_literal: true

require 'uri'
require 'fileutils'
require 'set'
@@ -1,3 +1,5 @@
# frozen_string_literal: true

Gem::Specification.new do |s|
s.name = "rack"
s.version = File.read('lib/rack.rb')[/RELEASE += +([\"\'])([\d][\w\.]+)\1/, 2]
@@ -1,3 +1,5 @@
# frozen_string_literal: true

=begin
=end
@@ -1,3 +1,5 @@
# frozen_string_literal: true

run lambda { |env| [200, {'Content-Type' => 'text/plain'}, ['OK']] }
__END__
Should not be evaluated
@@ -1 +1,3 @@
# frozen_string_literal: true

run lambda{ |env| [200, {'Content-Type' => 'text/plain'}, [__LINE__.to_s]] }
@@ -1,2 +1,4 @@
# frozen_string_literal: true

#\ -d -p 2929 --env test
run lambda { |env| [200, {'Content-Type' => 'text/plain'}, ['OK']] }
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# -*- ruby -*-

require '../testrequest'
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

# -*- ruby -*-

$: << File.join(File.dirname(__FILE__), "..", "..", "lib")
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

# -*- ruby -*-

require 'uri'
BIN +30 Bytes (120%) test/cgi/test.gz
Binary file not shown.
@@ -1,4 +1,6 @@
#!../../bin/rackup
# frozen_string_literal: true

# -*- ruby -*-

require '../testrequest'
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "#{File.dirname(__FILE__)}/../testrequest"

$stderr = File.open("#{File.dirname(__FILE__)}/log_output", "w")
@@ -199,7 +199,7 @@ def call(env) @a = 1 if env['PATH_INFO'] == '/a'; @app.call(env) end
end)
o = Object.new
def o.call(env)
@a = 1 if env['PATH_INFO'] == '/b';
@a = 1 if env['PATH_INFO'] == '/b';
[200, {}, []]
end
run o
@@ -256,7 +256,7 @@ def config_file(name)

it "sets __LINE__ correctly" do
app, _ = Rack::Builder.parse_file config_file('line.ru')
Rack::MockRequest.new(app).get("/").body.to_s.must_equal '1'
Rack::MockRequest.new(app).get("/").body.to_s.must_equal '3'
end
end

@@ -158,8 +158,8 @@ def file(*args)

res.status.must_equal 206
res["Content-Length"].must_equal "12"
res["Content-Range"].must_equal "bytes 22-33/193"
res.body.must_equal "-*- ruby -*-"
res["Content-Range"].must_equal "bytes 22-33/224"
res.body.must_equal "frozen_strin"
end

it "return error for unsatisfiable byte range" do
@@ -168,7 +168,7 @@ def file(*args)
res = Rack::MockResponse.new(*file(DOCROOT).call(env))

res.status.must_equal 416
res["Content-Range"].must_equal "bytes */193"
res["Content-Range"].must_equal "bytes */224"
end

it "support custom http headers" do
@@ -220,7 +220,7 @@ def file(*args)
req = Rack::MockRequest.new(Rack::Lint.new(Rack::File.new(DOCROOT)))
res = req.head "/cgi/test"
res.must_be :successful?
res['Content-Length'].must_equal "193"
res['Content-Length'].must_equal "224"
end

it "default to a mime type of text/plain" do

0 comments on commit b3d01da

Please sign in to comment.
You can’t perform that action at this time.