danger-wcc 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +46 -0
- data/.gitignore +6 -0
- data/.rubocop.yml +219 -0
- data/.ruby-version +1 -0
- data/.travis.yml +12 -0
- data/Dangerfile +5 -0
- data/Gemfile +6 -0
- data/Guardfile +35 -0
- data/LICENSE +201 -0
- data/README.md +2 -0
- data/Rakefile +25 -0
- data/danger-wcc.gemspec +58 -0
- data/lib/danger_plugin.rb +3 -0
- data/lib/version.rb +5 -0
- data/lib/wcc/commit_lint.rb +158 -0
- data/lib/wcc/commit_lint/README.md +3 -0
- data/lib/wcc/commit_lint/commit_check.rb +19 -0
- data/lib/wcc/commit_lint/empty_line_check.rb +22 -0
- data/lib/wcc/commit_lint/subject_cap_check.rb +22 -0
- data/lib/wcc/commit_lint/subject_length_check.rb +28 -0
- data/lib/wcc/commit_lint/subject_period_check.rb +22 -0
- data/lib/wcc/commit_lint/subject_words_check.rb +22 -0
- data/lib/wcc/default.jshintrc +5 -0
- data/lib/wcc/defaults.reek +131 -0
- data/lib/wcc/github.rb +24 -0
- data/lib/wcc/jshint.rb +63 -0
- data/lib/wcc/plugin.rb +128 -0
- data/lib/wcc/reek.rb +56 -0
- data/lib/wcc/rubocop_exceptions.rb +99 -0
- data/lib/wcc/todos.rb +78 -0
- data/lib/wcc/utils.rb +136 -0
- data/spec/fixtures/brakeman/a.tmp +13 -0
- data/spec/fixtures/brakeman/b.tmp +14 -0
- data/spec/fixtures/brakeman/brakeman.diff +20 -0
- data/spec/fixtures/brakeman/brakeman.out +14 -0
- data/spec/fixtures/exception_context.diff +15 -0
- data/spec/fixtures/exception_insert_context.diff +14 -0
- data/spec/fixtures/exception_misspelled.diff +14 -0
- data/spec/fixtures/exception_multiline_context.diff +20 -0
- data/spec/fixtures/exception_reenabled.diff +13 -0
- data/spec/fixtures/find_in_diff.rb +21 -0
- data/spec/fixtures/find_in_diff_2_chunks.diff +24 -0
- data/spec/fixtures/flay.diff +17 -0
- data/spec/fixtures/flay.txt +18 -0
- data/spec/fixtures/github/labels.json +72 -0
- data/spec/fixtures/github_pr.json +325 -0
- data/spec/fixtures/jshint/a.tmp +5 -0
- data/spec/fixtures/jshint/b.tmp +7 -0
- data/spec/fixtures/jshint/jshint.diff +13 -0
- data/spec/fixtures/jshint/out.jshint +7 -0
- data/spec/fixtures/no_exception.diff +10 -0
- data/spec/fixtures/no_todo.diff +13 -0
- data/spec/fixtures/reek/line_numbers.reek +121 -0
- data/spec/fixtures/reek/reek.diff +50 -0
- data/spec/fixtures/rubocop_exception.rb +39 -0
- data/spec/fixtures/todo.rb +21 -0
- data/spec/fixtures/todo_link_next_line.diff +14 -0
- data/spec/fixtures/todo_link_same_line.diff +13 -0
- data/spec/fixtures/todo_no_link.diff +13 -0
- data/spec/fixtures/todo_removed.diff +13 -0
- data/spec/fixtures_helper.rb +19 -0
- data/spec/spec_helper.rb +73 -0
- data/spec/wcc/commit_lint_spec.rb +392 -0
- data/spec/wcc/github_spec.rb +67 -0
- data/spec/wcc/jshint_spec.rb +68 -0
- data/spec/wcc/plugin_spec.rb +134 -0
- data/spec/wcc/reek_spec.rb +71 -0
- data/spec/wcc/rubocop_exceptions_spec.rb +136 -0
- data/spec/wcc/todos_spec.rb +96 -0
- data/spec/wcc/utils_spec.rb +134 -0
- data/spec/wcc_spec.rb +21 -0
- metadata +393 -0
data/lib/wcc/utils.rb
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'git_diff'
|
5
|
+
require 'logger'
|
6
|
+
|
7
|
+
module Utils
|
8
|
+
def plugin
|
9
|
+
# individual check classes usually set the '@plugin' variable,
|
10
|
+
# otherwise this mixin was included on the plugin itself.
|
11
|
+
@plugin || self
|
12
|
+
end
|
13
|
+
|
14
|
+
def logger
|
15
|
+
return @logger if @logger
|
16
|
+
@logger = Logger.new(STDERR)
|
17
|
+
@logger.level = ENV['DANGER_LOG_LEVEL'] ||
|
18
|
+
(plugin.verbose ? Logger::INFO : Logger::ERROR)
|
19
|
+
@logger
|
20
|
+
end
|
21
|
+
|
22
|
+
# All the diffs in the PR parsed into GitDiff objects
|
23
|
+
def parsed_diffs
|
24
|
+
@parsed_diffs ||=
|
25
|
+
plugin.git.diff.map do |d|
|
26
|
+
begin
|
27
|
+
GitDiff.from_string(d.patch)
|
28
|
+
rescue StandardError
|
29
|
+
logger.fatal "Error parsing patch:\n#{d.patch}"
|
30
|
+
raise
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Finds lines in the overall diff matching the given regex, and
|
36
|
+
# executes a block for each matched line.
|
37
|
+
# The results of the yield block are returned as an array.
|
38
|
+
def find_in_diff(regex)
|
39
|
+
each_file_in_diff do |file, diff|
|
40
|
+
file.hunks.flat_map do |hunk|
|
41
|
+
lines = hunk.lines.select { |l| l.addition? && l.content =~ regex }
|
42
|
+
if block_given?
|
43
|
+
lines =
|
44
|
+
lines.map do |l|
|
45
|
+
yield(l.content.match(regex), l, hunk, file, diff)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
lines
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def each_file_in_diff(passed_diff = nil)
|
54
|
+
diffs = passed_diff ? [passed_diff] : parsed_diffs
|
55
|
+
diffs.flat_map do |diff|
|
56
|
+
diff.files.flat_map do |file|
|
57
|
+
yield(file, diff)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def each_addition_in_diff(passed_diff = nil)
|
63
|
+
each_file_in_diff(passed_diff) do |file, diff|
|
64
|
+
file.hunks.flat_map do |hunk|
|
65
|
+
lines = hunk.lines.select(&:addition?)
|
66
|
+
lines = lines.map { |l| yield(l, hunk, file, diff) } if block_given?
|
67
|
+
lines
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def run(command)
|
73
|
+
logger.info "Executing command '#{command}'"
|
74
|
+
result = `#{command}`
|
75
|
+
logger.debug result
|
76
|
+
result
|
77
|
+
end
|
78
|
+
|
79
|
+
# Runs a command twice - once on the merge base, and once on the current
|
80
|
+
# working directory. Then, returns the git diff of the printed results.
|
81
|
+
def run_and_diff(command = nil)
|
82
|
+
unless command || block_given?
|
83
|
+
raise ArgumentError('Must give command or block')
|
84
|
+
end
|
85
|
+
|
86
|
+
logger.info "Executing diff: '#{command}'"
|
87
|
+
with_revision(plugin.github.base_commit) do |dir|
|
88
|
+
initial = nil
|
89
|
+
Dir.chdir(dir) do
|
90
|
+
initial = command ? `#{command}` : yield
|
91
|
+
end
|
92
|
+
final = command ? `#{command}` : yield
|
93
|
+
|
94
|
+
diff = diff_strings(initial, final)
|
95
|
+
logger.debug diff
|
96
|
+
diff
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# Executes a block after checking out the specified revision into a temp
|
101
|
+
# directory.
|
102
|
+
def with_revision(revision)
|
103
|
+
Dir.mktmpdir do |dir|
|
104
|
+
logger.debug "Checking out revision #{revision} into #{dir}"
|
105
|
+
system "git --work-tree=#{dir} checkout #{revision.strip} -- ."
|
106
|
+
|
107
|
+
yield(dir)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# Creates a git-format diff of the two strings by writing them to temp files
|
112
|
+
def diff_strings(a, b)
|
113
|
+
File.write('a.tmp', a)
|
114
|
+
File.write('b.tmp', b)
|
115
|
+
diff = `git diff --no-index a.tmp b.tmp`
|
116
|
+
File.delete('a.tmp', 'b.tmp')
|
117
|
+
diff
|
118
|
+
end
|
119
|
+
|
120
|
+
def format_links_as_markdown(line)
|
121
|
+
line.gsub(/\[?(https?\:\/\/[^\s\]]+)\]?/i, '[\1](\1)')
|
122
|
+
end
|
123
|
+
|
124
|
+
# Adds a message to the Danger report
|
125
|
+
# with the given serverity - 'message', 'warn', or 'fail
|
126
|
+
def issue(message, severity: 'message', file: nil, line: nil)
|
127
|
+
case severity
|
128
|
+
when 'message'
|
129
|
+
plugin.message(message, file: file, line: line)
|
130
|
+
when 'warn'
|
131
|
+
plugin.warn(message, file: file, line: line)
|
132
|
+
else
|
133
|
+
plugin.fail(message, file: file, line: line)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
app/controllers/wmoauth_controller.rb Redirect General Possible unprotected redirect near line : redirect_to(Wmoauth.get_client.auth_code.authorize_url(:redirect_uri => ENV["REDIRECT_URI"])) High
|
2
|
+
app/controllers/webhooks_controller.rb Cross Site Request Forgery Controller 'protect_from_forgery' should be called in WebhooksController near line High
|
3
|
+
|
4
|
+
app/views/calendar/show.html.erb Cross Site Scripting Template Unescaped model attribute near line : Calendar.format_calendar_data(Entry.find_by_date((params[:id] + "--"), (params[:id] + "--"), )).to_s Medium
|
5
|
+
app/views/sections/_central_truth.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["central_truth"]["journey_central_truth"] High
|
6
|
+
app/views/sections/_introduction.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["introduction"]["journey_introduction"] High
|
7
|
+
app/views/sections/_introduction.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["introduction"]["journey_introduction"] High
|
8
|
+
app/views/sections/_introduction.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["introduction"]["journey_introduction"] High
|
9
|
+
app/views/sections/_key_verse.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["key_verse"]["journey_key_verse_html"] High
|
10
|
+
app/views/sections/_scripture_memory.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["scripture_memory"]["journey_scripture_memory_html"] High
|
11
|
+
app/views/sections/_tweetable_truth.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["tweetable_truth"]["journey_tweetable_truth"] High
|
12
|
+
app/views/sections/_writer.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["writer"]["journey_writer_bio"] High
|
13
|
+
app/views/sections/comments/_group_comments.html.erb Cross Site Scripting Template Unescaped model attribute near line : { post["post_number"] => ({ :raw => post["cooked"], :name => post["name"], :reply_count => post["reply_count"], :created_at => post["created_at"], :reply_to_post_number => post["reply_to_post_number"], :post_number => post["post_number"] }) }[(Unresolved Model).new.post_no][:raw] Weak
|
@@ -0,0 +1,14 @@
|
|
1
|
+
app/controllers/wmoauth_controller.rb Redirect General Possible unprotected redirect near line : redirect_to(Wmoauth.get_client.auth_code.authorize_url(:redirect_uri => ENV["REDIRECT_URI"])) High
|
2
|
+
app/controllers/wmoauth_controller.rb SSL Verification Bypass General SSL certificate verification was bypassed near line : Net::HTTP.new(URI.parse(URI.escape("https://jointhejourney.us.list-manage.com/subscribe/post?u=#{ENV["MAILCHIMP_ORG_ID"]}&id=#{ENV["MAILCHIMP_LIST_ID"]}&FNAME=#{user["first_name"]}&LNAME=#{user["last_name"]}&EMAIL=#{user["email"]}")).host, URI.parse(URI.escape("https://jointhejourney.us.list-manage.com/subscribe/post?u=#{ENV["MAILCHIMP_ORG_ID"]}&id=#{ENV["MAILCHIMP_LIST_ID"]}&FNAME=#{user["first_name"]}&LNAME=#{user["last_name"]}&EMAIL=#{user["email"]}")).port).verify_mode = OpenSSL::SSL::VERIFY_NONE High
|
3
|
+
app/controllers/webhooks_controller.rb Cross Site Request Forgery Controller 'protect_from_forgery' should be called in WebhooksController near line High
|
4
|
+
|
5
|
+
app/views/calendar/show.html.erb Cross Site Scripting Template Unescaped model attribute near line : Calendar.format_calendar_data(Entry.find_by_date((params[:id] + "--"), (params[:id] + "--"), )).to_s Medium
|
6
|
+
app/views/sections/_central_truth.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["central_truth"]["journey_central_truth"] High
|
7
|
+
app/views/sections/_discussion_questions.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["discussion_questions"]["journey_discussion_questions"] High
|
8
|
+
app/views/sections/_introduction.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["introduction"]["journey_introduction"] High
|
9
|
+
app/views/sections/_introduction.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["introduction"]["journey_introduction"] High
|
10
|
+
app/views/sections/_introduction.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["introduction"]["journey_introduction"] High
|
11
|
+
app/views/sections/_key_verse.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["key_verse"]["journey_key_verse_html"] High
|
12
|
+
app/views/sections/_scripture_memory.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["scripture_memory"]["journey_scripture_memory_html"] High
|
13
|
+
app/views/sections/_tweetable_truth.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["tweetable_truth"]["journey_tweetable_truth"] High
|
14
|
+
app/views/sections/_writer.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["writer"]["journey_writer_bio"] High
|
@@ -0,0 +1,20 @@
|
|
1
|
+
diff --git a/a.tmp b/b.tmp
|
2
|
+
index 1652641..f6e16b1 100644
|
3
|
+
--- a/a.tmp
|
4
|
+
+++ b/b.tmp
|
5
|
+
@@ -1,8 +1,10 @@
|
6
|
+
app/controllers/wmoauth_controller.rb Redirect General Possible unprotected redirect near line : redirect_to(Wmoauth.get_client.auth_code.authorize_url(:redirect_uri => ENV["REDIRECT_URI"])) High
|
7
|
+
+app/controllers/wmoauth_controller.rb SSL Verification Bypass General SSL certificate verification was bypassed near line : Net::HTTP.new(URI.parse(URI.escape("https://jointhejourney.us.list-manage.com/subscribe/post?u=#{ENV["MAILCHIMP_ORG_ID"]}&id=#{ENV["MAILCHIMP_LIST_ID"]}&FNAME=#{user["first_name"]}&LNAME=#{user["last_name"]}&EMAIL=#{user["email"]}")).host, URI.parse(URI.escape("https://jointhejourney.us.list-manage.com/subscribe/post?u=#{ENV["MAILCHIMP_ORG_ID"]}&id=#{ENV["MAILCHIMP_LIST_ID"]}&FNAME=#{user["first_name"]}&LNAME=#{user["last_name"]}&EMAIL=#{user["email"]}")).port).verify_mode = OpenSSL::SSL::VERIFY_NONE High
|
8
|
+
app/controllers/webhooks_controller.rb Cross Site Request Forgery Controller 'protect_from_forgery' should be called in WebhooksController near line High
|
9
|
+
|
10
|
+
app/views/calendar/show.html.erb Cross Site Scripting Template Unescaped model attribute near line : Calendar.format_calendar_data(Entry.find_by_date((params[:id] + "--"), (params[:id] + "--"), )).to_s Medium
|
11
|
+
app/views/sections/_central_truth.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["central_truth"]["journey_central_truth"] High
|
12
|
+
+app/views/sections/_discussion_questions.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["discussion_questions"]["journey_discussion_questions"] High
|
13
|
+
app/views/sections/_introduction.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["introduction"]["journey_introduction"] High
|
14
|
+
app/views/sections/_introduction.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["introduction"]["journey_introduction"] High
|
15
|
+
app/views/sections/_introduction.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["introduction"]["journey_introduction"] High
|
16
|
+
@@ -10,4 +12,3 @@ app/views/sections/_key_verse.html.erb Cross Site Scripting Template Unescaped
|
17
|
+
app/views/sections/_scripture_memory.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["scripture_memory"]["journey_scripture_memory_html"] High
|
18
|
+
app/views/sections/_tweetable_truth.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["tweetable_truth"]["journey_tweetable_truth"] High
|
19
|
+
app/views/sections/_writer.html.erb Cross Site Scripting Template Unescaped model attribute near line : Entry.find(params[:id], params[:preview_code])["writer"]["journey_writer_bio"] High
|
20
|
+
-app/views/sections/comments/_group_comments.html.erb Cross Site Scripting Template Unescaped model attribute near line : { post["post_number"] => ({ :raw => post["cooked"], :name => post["name"], :reply_count => post["reply_count"], :created_at => post["created_at"], :reply_to_post_number => post["reply_to_post_number"], :post_number => post["post_number"] }) }[(Unresolved Model).new.post_no][:raw] Weak
|
@@ -0,0 +1,14 @@
|
|
1
|
+
app/controllers/wmoauth_controller.rb 11 Redirect General Possible unprotected redirect near line 11: redirect_to(Wmoauth.get_client.auth_code.authorize_url(:redirect_uri => ENV["REDIRECT_URI"])) High
|
2
|
+
app/controllers/wmoauth_controller.rb 78 SSL Verification Bypass General SSL certificate verification was bypassed near line 78: Net::HTTP.new(URI.parse(URI.escape("https://jointhejourney.us3.list-manage.com/subscribe/post?u=#{ENV["MAILCHIMP_ORG_ID"]}&id=#{ENV["MAILCHIMP_LIST_ID"]}&FNAME=#{user["first_name"]}&LNAME=#{user["last_name"]}&EMAIL=#{user["email"]}")).host, URI.parse(URI.escape("https://jointhejourney.us3.list-manage.com/subscribe/post?u=#{ENV["MAILCHIMP_ORG_ID"]}&id=#{ENV["MAILCHIMP_LIST_ID"]}&FNAME=#{user["first_name"]}&LNAME=#{user["last_name"]}&EMAIL=#{user["email"]}")).port).verify_mode = OpenSSL::SSL::VERIFY_NONE High
|
3
|
+
app/controllers/webhooks_controller.rb 2 Cross Site Request Forgery Controller 'protect_from_forgery' should be called in WebhooksController near line 2 High
|
4
|
+
|
5
|
+
app/views/calendar/show.html.erb 76 Cross Site Scripting Template Unescaped model attribute near line 76: Calendar.format_calendar_data(Entry.find_by_date((params[:id] + "-1-1"), (params[:id] + "-12-31"), 300)).to_s Medium
|
6
|
+
app/views/sections/_central_truth.html.erb 4 Cross Site Scripting Template Unescaped model attribute near line 4: Entry.find(params[:id], params[:preview_code])["central_truth"]["journey_central_truth"] High
|
7
|
+
app/views/sections/_discussion_questions.html.erb 4 Cross Site Scripting Template Unescaped model attribute near line 4: Entry.find(params[:id], params[:preview_code])["discussion_questions"]["journey_discussion_questions"] High
|
8
|
+
app/views/sections/_introduction.html.erb 31 Cross Site Scripting Template Unescaped model attribute near line 31: Entry.find(params[:id], params[:preview_code])["introduction"]["journey_introduction"] High
|
9
|
+
app/views/sections/_introduction.html.erb 41 Cross Site Scripting Template Unescaped model attribute near line 41: Entry.find(params[:id], params[:preview_code])["introduction"]["journey_introduction"] High
|
10
|
+
app/views/sections/_introduction.html.erb 57 Cross Site Scripting Template Unescaped model attribute near line 57: Entry.find(params[:id], params[:preview_code])["introduction"]["journey_introduction"] High
|
11
|
+
app/views/sections/_key_verse.html.erb 6 Cross Site Scripting Template Unescaped model attribute near line 6: Entry.find(params[:id], params[:preview_code])["key_verse"]["journey_key_verse_html"] High
|
12
|
+
app/views/sections/_scripture_memory.html.erb 12 Cross Site Scripting Template Unescaped model attribute near line 12: Entry.find(params[:id], params[:preview_code])["scripture_memory"]["journey_scripture_memory_html"] High
|
13
|
+
app/views/sections/_tweetable_truth.html.erb 10 Cross Site Scripting Template Unescaped model attribute near line 10: Entry.find(params[:id], params[:preview_code])["tweetable_truth"]["journey_tweetable_truth"] High
|
14
|
+
app/views/sections/_writer.html.erb 31 Cross Site Scripting Template Unescaped model attribute near line 31: Entry.find(params[:id], params[:preview_code])["writer"]["journey_writer_bio"] High
|
@@ -0,0 +1,15 @@
|
|
1
|
+
diff --git a/spec/fixtures/rubocop_exception.rb b/spec/fixtures/rubocop_exception.rb
|
2
|
+
index 2122f05..1d51ff5 100644
|
3
|
+
--- a/spec/fixtures/rubocop_exception.rb
|
4
|
+
+++ b/spec/fixtures/rubocop_exception.rb
|
5
|
+
@@ -11,4 +11,10 @@ module RubocopException
|
6
|
+
def some_method_misspelled_reenable
|
7
|
+
end
|
8
|
+
# rubocop:enable Lint/SomLint
|
9
|
+
+
|
10
|
+
+ # rubocop:disable Metrics/LineLength
|
11
|
+
+ # Disabling because I want to.
|
12
|
+
+ def some_method_with_context
|
13
|
+
+ end
|
14
|
+
+ # rubocop:enable Metrics/LineLength
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
diff --git a/spec/fixtures/rubocop_exception.rb b/spec/fixtures/rubocop_exception.rb
|
2
|
+
index c97cbfc..0406593 100644
|
3
|
+
--- a/spec/fixtures/rubocop_exception.rb
|
4
|
+
+++ b/spec/fixtures/rubocop_exception.rb
|
5
|
+
@@ -20,6 +20,9 @@ module RubocopException
|
6
|
+
|
7
|
+
+ # rubocop:disable Metrics/ABC
|
8
|
+
+ # here is my comment why we are disabling ABC
|
9
|
+
# Some existing comments
|
10
|
+
# Made by another person
|
11
|
+
def some_method_with_existing_comments
|
12
|
+
end
|
13
|
+
+ # rubocop:enable Metrics/ABC
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
diff --git a/spec/fixtures/rubocop_exception.rb b/spec/fixtures/rubocop_exception.rb
|
2
|
+
index 7f63af5..2122f05 100644
|
3
|
+
--- a/spec/fixtures/rubocop_exception.rb
|
4
|
+
+++ b/spec/fixtures/rubocop_exception.rb
|
5
|
+
@@ -6,4 +6,9 @@ module RubocopException
|
6
|
+
def some_method_with_disabled_rule
|
7
|
+
end
|
8
|
+
# rubocop:enable Rails/SomeRule
|
9
|
+
+
|
10
|
+
+ # rubocop:disable Lint/SomeLint
|
11
|
+
+ def some_method_misspelled_reenable
|
12
|
+
+ end
|
13
|
+
+ # rubocop:enable Lint/SomLint
|
14
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
diff --git a/spec/fixtures/rubocop_exception.rb b/spec/fixtures/rubocop_exception.rb
|
2
|
+
index 0406593..c59d48e 100644
|
3
|
+
--- a/spec/fixtures/rubocop_exception.rb
|
4
|
+
+++ b/spec/fixtures/rubocop_exception.rb
|
5
|
+
@@ -25,4 +25,15 @@ module RubocopException
|
6
|
+
def some_method_with_existing_comments
|
7
|
+
end
|
8
|
+
# rubocop:enable Metrics/ABC
|
9
|
+
+
|
10
|
+
+ def some_method_with_multiline_context
|
11
|
+
+ # rubocop:disable Layout/AlignHash
|
12
|
+
+ # I want to disable this because..
|
13
|
+
+ # I forgot the reasons.
|
14
|
+
+ {
|
15
|
+
+ a: 'a',
|
16
|
+
+ b: 'b'
|
17
|
+
+ }
|
18
|
+
+ # rubocop:enable Layout/AlignHash
|
19
|
+
+ end
|
20
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
diff --git a/spec/fixtures/rubocop_exception.rb b/spec/fixtures/rubocop_exception.rb
|
2
|
+
index 663661c..7f63af5 100644
|
3
|
+
--- a/spec/fixtures/rubocop_exception.rb
|
4
|
+
+++ b/spec/fixtures/rubocop_exception.rb
|
5
|
+
@@ -2,4 +2,8 @@
|
6
|
+
# frozen_string_literal: true
|
7
|
+
|
8
|
+
module RubocopException
|
9
|
+
+ # rubocop:disable Rails/SomeRule
|
10
|
+
+ def some_method_with_disabled_rule
|
11
|
+
+ end
|
12
|
+
+ # rubocop:enable Rails/SomeRule
|
13
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FindInDiff
|
4
|
+
def added_hunk_1
|
5
|
+
# This should appear in hunk 1
|
6
|
+
end
|
7
|
+
|
8
|
+
def method_in_the_middle
|
9
|
+
# Something something...
|
10
|
+
|
11
|
+
# This is several rows wide
|
12
|
+
|
13
|
+
# So that it has to end up in multiple hunks
|
14
|
+
|
15
|
+
# la dee da...
|
16
|
+
end
|
17
|
+
|
18
|
+
def added_hunk_2
|
19
|
+
# This should appear in hunk 2
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
diff --git a/spec/fixtures/find_in_diff.rb b/spec/fixtures/find_in_diff.rb
|
2
|
+
index ea14920..bef5732 100644
|
3
|
+
--- a/spec/fixtures/find_in_diff.rb
|
4
|
+
+++ b/spec/fixtures/find_in_diff.rb
|
5
|
+
@@ -1,6 +1,10 @@
|
6
|
+
# frozen_string_literal: true
|
7
|
+
|
8
|
+
module FindInDiff
|
9
|
+
+ def added_hunk_1
|
10
|
+
+ # This should appear in hunk 1
|
11
|
+
+ end
|
12
|
+
+
|
13
|
+
def method_in_the_middle
|
14
|
+
# Something something...
|
15
|
+
|
16
|
+
@@ -10,4 +14,8 @@ module FindInDiff
|
17
|
+
|
18
|
+
# la dee da...
|
19
|
+
end
|
20
|
+
+
|
21
|
+
+ def added_hunk_2
|
22
|
+
+ # This should appear in hunk 2
|
23
|
+
+ end
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
diff --git a/app/models/discourse.rb b/app/models/discourse.rb
|
2
|
+
index 5451817..93b5fdf 100644
|
3
|
+
--- a/app/models/discourse.rb
|
4
|
+
+++ b/app/models/discourse.rb
|
5
|
+
@@ -121,6 +121,12 @@ class Discourse
|
6
|
+
prefix_var = ENV['DISCOURSE_TOPIC_PREFIX']
|
7
|
+
prefix = '-' + prefix_var unless prefix_var.blank?
|
8
|
+
|
9
|
+
+ if entry['title'].nil?
|
10
|
+
+ title= "JTJ#{prefix.to_s}-#{Date.parse(entry['date']).strftime("%Y/%m/%d")}"
|
11
|
+
+ else
|
12
|
+
+ title= "JTJ#{prefix.to_s}-#{Date.parse(entry['date']).strftime("%Y/%m/%d")}-#{entry['title']}"
|
13
|
+
+ end
|
14
|
+
+
|
15
|
+
topic = Topic.find_by(entry_id: entry['id'])
|
16
|
+
unless topic.present?
|
17
|
+
Rails.logger.info "[Discourse](create_discourse_topic) Creating new topic for entry #{entry} with title #{title}"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Total score (lower is better) = 502
|
2
|
+
|
3
|
+
1) IDENTICAL code found in :iter (mass*2 = 232)
|
4
|
+
app/controllers/pages_controller.rb:41
|
5
|
+
app/controllers/pages_controller.rb:96
|
6
|
+
|
7
|
+
2) IDENTICAL code found in :if (mass*2 = 152)
|
8
|
+
app/models/discourse.rb:124
|
9
|
+
app/models/discourse.rb:177
|
10
|
+
|
11
|
+
3) IDENTICAL code found in :lasgn (mass*2 = 64)
|
12
|
+
app/helpers/application_helper.rb:3
|
13
|
+
app/mailers/jtj_mailer.rb:39
|
14
|
+
|
15
|
+
4) Similar code found in :defn (mass = 54)
|
16
|
+
app/controllers/pages_controller.rb:127
|
17
|
+
app/controllers/pages_controller.rb:134
|
18
|
+
app/controllers/pages_controller.rb:141
|
@@ -0,0 +1,72 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"id": 662033598,
|
4
|
+
"url": "https://api.github.com/repos/watermarkchurch/jtj-cms/labels/backlog",
|
5
|
+
"name": "backlog",
|
6
|
+
"color": "ededed",
|
7
|
+
"default": false
|
8
|
+
},
|
9
|
+
{
|
10
|
+
"id": 592468992,
|
11
|
+
"url": "https://api.github.com/repos/watermarkchurch/jtj-cms/labels/bug",
|
12
|
+
"name": "bug",
|
13
|
+
"color": "ee0701",
|
14
|
+
"default": true
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"id": 592468993,
|
18
|
+
"url": "https://api.github.com/repos/watermarkchurch/jtj-cms/labels/duplicate",
|
19
|
+
"name": "duplicate",
|
20
|
+
"color": "cccccc",
|
21
|
+
"default": true
|
22
|
+
},
|
23
|
+
{
|
24
|
+
"id": 592468994,
|
25
|
+
"url": "https://api.github.com/repos/watermarkchurch/jtj-cms/labels/enhancement",
|
26
|
+
"name": "enhancement",
|
27
|
+
"color": "84b6eb",
|
28
|
+
"default": true
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"id": 592468995,
|
32
|
+
"url": "https://api.github.com/repos/watermarkchurch/jtj-cms/labels/help%20wanted",
|
33
|
+
"name": "help wanted",
|
34
|
+
"color": "128A0C",
|
35
|
+
"default": true
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"id": 592468996,
|
39
|
+
"url": "https://api.github.com/repos/watermarkchurch/jtj-cms/labels/invalid",
|
40
|
+
"name": "invalid",
|
41
|
+
"color": "e6e6e6",
|
42
|
+
"default": true
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"id": 765977835,
|
46
|
+
"url": "https://api.github.com/repos/watermarkchurch/jtj-cms/labels/Ops",
|
47
|
+
"name": "Ops",
|
48
|
+
"color": "000000",
|
49
|
+
"default": false
|
50
|
+
},
|
51
|
+
{
|
52
|
+
"id": 592468997,
|
53
|
+
"url": "https://api.github.com/repos/watermarkchurch/jtj-cms/labels/question",
|
54
|
+
"name": "question",
|
55
|
+
"color": "cc317c",
|
56
|
+
"default": true
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"id": 782232325,
|
60
|
+
"url": "https://api.github.com/repos/watermarkchurch/jtj-cms/labels/schema%20changes",
|
61
|
+
"name": "schema changes",
|
62
|
+
"color": "82e5c7",
|
63
|
+
"default": false
|
64
|
+
},
|
65
|
+
{
|
66
|
+
"id": 592468999,
|
67
|
+
"url": "https://api.github.com/repos/watermarkchurch/jtj-cms/labels/wontfix",
|
68
|
+
"name": "wontfix",
|
69
|
+
"color": "ffffff",
|
70
|
+
"default": true
|
71
|
+
}
|
72
|
+
]
|