Skip to content

Commit 454ebb5

Browse files
committed
Update code using rubocop's autocorrect linter
1 parent ed508a9 commit 454ebb5

File tree

126 files changed

+724
-478
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+724
-478
lines changed

Rakefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/usr/bin/env rake
2+
# frozen_string_literal: true
3+
24
# Add your own tasks in files placed in lib/tasks ending in .rake,
35
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
46

5-
require File.expand_path('../config/application', __FILE__)
7+
require File.expand_path("../config/application", __FILE__)
68

79
Rake.application.options.trace = true
810

911
Gitscm::Application.load_tasks
10-

app/controllers/about_controller.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class AboutController < ApplicationController
24

35
def index

app/controllers/application_controller.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
# frozen_string_literal: true
2+
13
PageNotFound = Class.new(Exception)
24

35
class ApplicationController < ActionController::Base
46
protect_from_forgery
57
before_filter :determine_os
68

7-
rescue_from PageNotFound, :with => :page_not_found
9+
rescue_from PageNotFound, with: :page_not_found
810

911
# Mac, Windows, Linux are valid
1012
def determine_os
11-
@os = 'linux'
13+
@os = "linux"
1214
end
1315

1416
def set_title(title)
@@ -18,7 +20,7 @@ def set_title(title)
1820
private
1921

2022
def page_not_found
21-
render :file => not_found_template, :layout => false
23+
render file: not_found_template, layout: false
2224
end
2325

2426
def not_found_template

app/controllers/blog_controller.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
# frozen_string_literal: true
2+
13
class BlogController < ApplicationController
24
end

app/controllers/books_controller.rb

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
# frozen_string_literal: true
2+
13
class BooksController < ApplicationController
24
before_filter :book_resource, only: [:section, :chapter]
35

46
def show
57
lang = params[:lang] || "en"
68
if edition = params[:edition]
7-
@book = Book.where(:code => lang, :edition => edition).first
9+
@book = Book.where(code: lang, edition: edition).first
810
else
9-
@book = Book.where(:code => lang).order("percent_complete DESC, edition DESC").first
11+
@book = Book.where(code: lang).order("percent_complete DESC, edition DESC").first
1012
raise PageNotFound unless @book
1113
redirect_to "/book/#{lang}/v#{@book.edition}"
1214
end
@@ -15,18 +17,18 @@ def show
1517

1618
def link
1719
link = params[:link]
18-
@book = Book.where(:code => params[:lang], :edition => params[:edition]).first
20+
@book = Book.where(code: params[:lang], edition: params[:edition]).first
1921
raise PageNotFound unless @book
20-
xref = @book.xrefs.where(:name => link).first
22+
xref = @book.xrefs.where(name: link).first
2123
raise PageNotFound unless xref
2224
return redirect_to "/book/#{@book.code}/v#{@book.edition}/#{ERB::Util.url_encode(xref.section.slug)}##{xref.name}" unless @content
2325
end
2426

2527
def section
26-
@content = @book.sections.where(:slug => params[:slug]).first
28+
@content = @book.sections.where(slug: params[:slug]).first
2729
if !@content
28-
@book = Book.where(:code => @book.code, :edition => 1).first
29-
if @content = @book.sections.where(:slug => params[:slug]).first
30+
@book = Book.where(code: @book.code, edition: 1).first
31+
if @content = @book.sections.where(slug: params[:slug]).first
3032
return redirect_to "/book/#{@book.code}/v#{@book.edition}/#{params[:slug]}"
3133
else
3234
return redirect_to "/book/#{@book.code}"
@@ -45,18 +47,18 @@ def chapter
4547
chapter = params[:chapter].to_i
4648
section = params[:section].to_i
4749
lang = params[:lang] || "en"
48-
chapter = @book.chapters.where(:number => chapter).first
49-
@content = chapter.sections.where(:number => section).first
50+
chapter = @book.chapters.where(number: chapter).first
51+
@content = chapter.sections.where(number: section).first
5052
raise PageNotFound unless @content
5153
return redirect_to "/book/#{lang}/v2/#{@content.slug}"
5254
end
5355

5456
def book_resource
5557
if edition = params[:edition]
56-
@book ||= Book.where(:code => (params[:lang] || "en"), :edition => edition).first
58+
@book ||= Book.where(code: (params[:lang] || "en"), edition: edition).first
5759
else
5860
@no_edition = true
59-
@book ||= Book.where(:code => (params[:lang] || "en")).order("percent_complete DESC, edition DESC").first
61+
@book ||= Book.where(code: (params[:lang] || "en")).order("percent_complete DESC, edition DESC").first
6062
end
6163
raise PageNotFound unless @book
6264
@book

app/controllers/community_controller.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class CommunityController < ApplicationController
24

35
def index

app/controllers/doc_controller.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
class DocController < ApplicationController
24

35
before_filter :set_caching
@@ -30,7 +32,7 @@ def videos
3032

3133
def watch
3234
slug = params[:id]
33-
@video = Gitscm::VIDEOS.select{|a| a[4] == slug}.first
35+
@video = Gitscm::VIDEOS.select { |a| a[4] == slug }.first
3436
if !@video
3537
redirect_to :videos
3638
end
@@ -42,11 +44,11 @@ def ext
4244
private
4345

4446
def set_caching
45-
expires_in 10.minutes, :public => true
47+
expires_in 10.minutes, public: true
4648
end
4749

4850
def set_book
49-
@book ||= Book.where(:code => (params[:lang] || "en")).order("percent_complete, edition DESC").first
51+
@book ||= Book.where(code: (params[:lang] || "en")).order("percent_complete, edition DESC").first
5052
raise PageNotFound unless @book
5153
end
5254

app/controllers/downloads_controller.rb

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1+
# frozen_string_literal: true
2+
13
class DownloadsController < ApplicationController
24

35
def index
46
end
57

68
def latest
79
latest = Version.latest_version.name
8-
render :text => latest
10+
render text: latest
911
end
1012

1113
def guis
1214
guis_info = GuiPresenter.instance.guis_info
1315

14-
render "downloads/guis/index", :locals => {:guis_info => guis_info}
16+
render "downloads/guis/index", locals: {guis_info: guis_info}
1517
end
1618

1719
def logos
@@ -20,25 +22,25 @@ def logos
2022

2123
def gui
2224
@platform = params[:platform]
23-
@platform = 'windows' if @platform == 'win'
25+
@platform = "windows" if @platform == "win"
2426

2527
guis_info = GuiPresenter.instance.guis_info
2628

27-
render "downloads/guis/index", :locals => {:guis_info => guis_info}
29+
render "downloads/guis/index", locals: {guis_info: guis_info}
2830
end
2931

3032
def download
3133
@platform = params[:platform]
32-
@platform = 'windows' if @platform == 'win'
33-
if @platform == 'mac'
34+
@platform = "windows" if @platform == "win"
35+
if @platform == "mac"
3436
@project_url = "https://sourceforge.net/projects/git-osx-installer/"
3537
@source_url = "https://github.com/git/git/"
3638

3739
@download = Download.latest_for(@platform)
3840
@latest = Version.latest_version
3941

4042
render "downloads/downloading"
41-
elsif @platform == 'windows'
43+
elsif @platform == "windows"
4244
@project_url = "https://git-for-windows.github.io/"
4345
@source_url = "https://github.com/git-for-windows/git"
4446

@@ -57,12 +59,12 @@ def download
5759
end
5860

5961
render "downloads/download_windows"
60-
elsif @platform == 'linux'
62+
elsif @platform == "linux"
6163
render "downloads/download_linux"
6264
else
63-
redirect_to '/downloads'
65+
redirect_to "/downloads"
6466
end
6567
rescue
66-
redirect_to '/downloads'
68+
redirect_to "/downloads"
6769
end
6870
end

app/controllers/site_controller.rb

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1+
# frozen_string_literal: true
2+
13
class SiteController < ApplicationController
24

35
def index
4-
expires_in 10.minutes, :public => true
6+
expires_in 10.minutes, public: true
57

68
@section = "home"
79
@subsection = ""
810
end
911

1012
def search
11-
@term = sname = params['search'].to_s.downcase
13+
@term = sname = params["search"].to_s.downcase
1214
@data = search_term(sname)
13-
render :partial => 'shared/search'
15+
render partial: "shared/search"
1416
end
1517

1618
def search_results
17-
@term = sname = params['search'].to_s.downcase
19+
@term = sname = params["search"].to_s.downcase
1820
data = search_term(sname, true)
1921
@top = []
2022
@rest = []
@@ -29,20 +31,20 @@ def search_results
2931
end
3032
@top.sort! { |a, b| b[:score] <=> a[:score] }
3133
@rest.sort! { |a, b| b[:score] <=> a[:score] }
32-
render "results"
34+
render "site/results"
3335
end
3436

3537
def search_term(sname, highlight = false)
3638
data = {
37-
:term => sname,
38-
:results => []
39+
term: sname,
40+
results: []
3941
}
4042

4143
if results = Doc.search(sname)
4244
data[:results] << results
4345
end
4446

45-
if results = Section.search(sname, :lang => 'en')
47+
if results = Section.search(sname, lang: "en")
4648
data[:results] << results
4749
end
4850

@@ -57,8 +59,8 @@ def redirect_wgibtx
5759
end
5860

5961
def redirect_book
60-
current_uri = request.env['PATH_INFO']
61-
if current_uri == '/'
62+
current_uri = request.env["PATH_INFO"]
63+
if current_uri == "/"
6264
redirect_to "https://git-scm.com/book"
6365
else
6466
redirect_to "https://git-scm.com#{current_uri}"

app/helpers/application_helper.rb

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
require 'iso8601'
1+
# frozen_string_literal: true
2+
3+
require "iso8601"
24

35
module ApplicationHelper
46

@@ -13,7 +15,7 @@ def sidebar_link_options(section)
1315
end
1416

1517
def random_tagline
16-
content_tag(:em, '-' * 2) + Gitscm::TAGLINES.sample
18+
content_tag(:em, "-" * 2) + Gitscm::TAGLINES.sample
1719
end
1820

1921
def latest_version
@@ -26,19 +28,19 @@ def latest_version
2628
end
2729

2830
def latest_mac_installer
29-
@mac_installer ||= Download.latest_for 'mac'
30-
@mac_installer ? @mac_installer.version.name : ''
31+
@mac_installer ||= Download.latest_for "mac"
32+
@mac_installer ? @mac_installer.version.name : ""
3133
end
3234

3335
def latest_win_installer
34-
@win_installer ||= Download.latest_for 'windows32'
35-
@win_installer ? @win_installer.version.name : ''
36+
@win_installer ||= Download.latest_for "windows32"
37+
@win_installer ? @win_installer.version.name : ""
3638
end
3739

3840
def latest_release_date
3941
begin
4042
@version ||= Version.latest_version
41-
'(' + @version.committed.strftime("%Y-%m-%d") + ')'
43+
"(" + @version.committed.strftime("%Y-%m-%d") + ")"
4244
rescue
4345
""
4446
end

app/helpers/books_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
# frozen_string_literal: true
2+
13
module BooksHelper
24
end

app/helpers/doc_helper.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
# frozen_string_literal: true
2+
13
module DocHelper
24

35
def man(name, text = nil)
4-
link_to text || name.gsub(/^git-/, ''), doc_file_path(:file => name)
6+
link_to text || name.gsub(/^git-/, ""), doc_file_path(file: name)
57
end
68

79
def linkify(content, section)
810
next_page = section.next_slug
911
prev_page = section.prev_slug
10-
content.gsub('[[nav-next]]', next_page).gsub('[[nav-prev]]', prev_page)
12+
content.gsub("[[nav-next]]", next_page).gsub("[[nav-prev]]", prev_page)
1113
end
1214
end

app/helpers/site_helper.rb

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
# frozen_string_literal: true
2+
13
module SiteHelper
24
def highlight_no_html(high)
35
strip_tags(high.to_s)
4-
.gsub('[highlight]', '<span class="highlight">')
5-
.gsub('[xhighlight]', '</span>')
6+
.gsub("[highlight]", '<span class="highlight">')
7+
.gsub("[xhighlight]", "</span>")
68
end
79

810
def rchart(title, data, extra = nil)
@@ -36,11 +38,11 @@ def trchart(title, data, extra = nil)
3638

3739

3840
def gchart(title, data)
39-
labels = data.map {|v| v[0] }
40-
vals = data.map {|v| v[1] }
41-
42-
v = vals.join(',')
43-
l = labels.join('|')
41+
labels = data.map { |v| v[0] }
42+
vals = data.map { |v| v[1] }
43+
44+
v = vals.join(",")
45+
l = labels.join("|")
4446

4547
scale = vals.max
4648
c = "<img src=\"https://chart.googleapis.com/chart?"

app/models/book.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
# frozen_string_literal: true
2+
13
# t.string :code
24
# t.timestamps
3-
class Book < ActiveRecord::Base
5+
class Book < ApplicationRecord
46
has_many :chapters
5-
has_many :sections, :through => :chapters
7+
has_many :sections, through: :chapters
68
has_many :xrefs
79

810
def has_edition(number)
9-
Book.where(:edition => number, :code => self.code).count > 0
11+
Book.where(edition: number, code: self.code).count > 0
1012
end
1113
end

0 commit comments

Comments
 (0)