Skip to content

Commit

Permalink
Introduce RuboCop
Browse files Browse the repository at this point in the history
  • Loading branch information
yujinakayama committed Mar 12, 2015
1 parent 9cd6316 commit 18f3bdc
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 11 deletions.
7 changes: 7 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
inherit_from: .rubocop_todo.yml

Style/StringLiterals:
EnforcedStyle: double_quotes

Style/TrailingComma:
EnforcedStyleForMultiline: comma
103 changes: 103 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# This configuration was generated by `rubocop --auto-gen-config`
# on 2015-03-12 12:56:25 +0900 using RuboCop version 0.29.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
Metrics/AbcSize:
Max: 21

# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 169

# Offense count: 27
# Configuration parameters: AllowURI, URISchemes.
Metrics/LineLength:
Max: 122

# Offense count: 3
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 17

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/AndOr:
Enabled: false

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/BarePercentLiterals:
Enabled: false

# Offense count: 1
Style/ConstantName:
Enabled: false

# Offense count: 10
Style/Documentation:
Enabled: false

# Offense count: 3
Style/DoubleNegation:
Enabled: false

# Offense count: 1
# Configuration parameters: Exclude.
Style/FileName:
Enabled: false

# Offense count: 1
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Enabled: false

# Offense count: 1
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
Style/Next:
Enabled: false

# Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Style/PerlBackrefs:
Enabled: false

# Offense count: 10
# Configuration parameters: NamePrefix, NamePrefixBlacklist.
Style/PredicateName:
Enabled: false

# Offense count: 2
# Configuration parameters: MaxSlashes.
Style/RegexpLiteral:
Enabled: false

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/SignalException:
Enabled: false

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
Style/TrailingComma:
Enabled: false

# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: WordRegex.
Style/WordArray:
Enabled: false
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source 'https://rubygems.org'
source "https://rubygems.org"

# Specify your gem's dependencies in qiita-markdown.gemspec
gemspec
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require "bundler/gem_tasks"
require "rspec/core/rake_task"
require "rubocop/rake_task"

RSpec::Core::RakeTask.new(:spec)
task default: :spec
RuboCop::RakeTask.new(:style)
task default: [:spec, :style]
2 changes: 1 addition & 1 deletion lib/qiita/markdown/filters/code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Code < HTML::Pipeline::Filter
def call
result[:codes] ||= []
doc.search("pre").each do |pre|
if code = pre.at("code")
if (code = pre.at("code"))
label = Label.new(code["class"])
filename = label.filename
language = label.language
Expand Down
2 changes: 1 addition & 1 deletion lib/qiita/markdown/filters/syntax_highlight.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def initialize(default_language: nil, node: nil)

def call
outer = Nokogiri::HTML.fragment(%Q[<div class="code-frame" data-lang="#{language}">])
frame = outer.at('div')
frame = outer.at("div")
frame.add_child(filename_node) if filename
frame.add_child(highlighted_node)
@node.replace(outer)
Expand Down
2 changes: 1 addition & 1 deletion lib/qiita/markdown/filters/toc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def has_first_child?
end

def id
@node.text.downcase.gsub(/[^\p{Word}\- ]/u, '').gsub(' ', '-')
@node.text.downcase.gsub(/[^\p{Word}\- ]/u, "").gsub(" ", "-")
end

def increment
Expand Down
1 change: 1 addition & 0 deletions qiita-markdown.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "pry"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec", "3.1.0"
spec.add_development_dependency "rubocop", "~> 0.29"
end
10 changes: 5 additions & 5 deletions spec/qiita/markdown/processor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,13 @@
@justin
@justin
@mallory@github
@#{?o * 33}
@#{'o' * 33}
@oo
EOS
end

it "extracts mentions correctly" do
expect(result[:mentioned_usernames]).to eq %W[
expect(result[:mentioned_usernames]).to eq %w[
alice
dave
ell_en
Expand Down Expand Up @@ -522,7 +522,7 @@
end
end

context 'with footenotes syntax' do
context "with footenotes syntax" do
let(:markdown) do
<<-EOS.strip_heredoc
[^1]
Expand All @@ -548,7 +548,7 @@
end
end

context 'with manually written link inside of <sup> tag' do
context "with manually written link inside of <sup> tag" do
let(:markdown) do
<<-EOS.strip_heredoc
<sup>[Qiita](http://qiita.com/)</sup>
Expand All @@ -562,7 +562,7 @@
end
end

context 'with manually written <a> tag with strange href inside of <sup> tag' do
context "with manually written <a> tag with strange href inside of <sup> tag" do
let(:markdown) do
<<-EOS.strip_heredoc
<sup><a href="#foo.1">Link</a></sup>
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
mocks.verify_partial_doubles = true
end

config.default_formatter = 'doc'
config.default_formatter = "doc"
config.filter_run :focus
config.run_all_when_everything_filtered = true
end

0 comments on commit 18f3bdc

Please sign in to comment.