rubocop updates
This commit is contained in:
parent
2691a3ef96
commit
857b9e6f53
36
.rubocop.yml
36
.rubocop.yml
|
@ -18,3 +18,39 @@ Metrics/MethodLength:
|
|||
Style/FileName:
|
||||
Exclude:
|
||||
- 'bin/git-generate-changelog'
|
||||
|
||||
#TODOS
|
||||
# Offense count: 14
|
||||
Metrics/AbcSize:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 1
|
||||
Style/AccessorMethodName:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 10
|
||||
Style/Documentation:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: MinBodyLength.
|
||||
Style/GuardClause:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
|
||||
# SupportedStyles: skip_modifier_ifs, always
|
||||
Style/Next:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 3
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
|
||||
# SupportedStyles: slashes, percent_r, mixed
|
||||
Style/RegexpLiteral:
|
||||
Enabled: false
|
||||
|
||||
Style/MutableConstant:
|
||||
Enabled: false
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config`
|
||||
# on 2016-02-23 12:36:44 +0200 using RuboCop version 0.37.2.
|
||||
# on 2016-02-23 17:18:27 +0200 using RuboCop version 0.37.2.
|
||||
# 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
|
||||
|
@ -11,10 +11,6 @@ Lint/ImplicitStringConcatenation:
|
|||
Exclude:
|
||||
- 'lib/github_changelog_generator/parser.rb'
|
||||
|
||||
# Offense count: 14
|
||||
Metrics/AbcSize:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 1
|
||||
Metrics/CyclomaticComplexity:
|
||||
Max: 7
|
||||
|
@ -22,30 +18,3 @@ Metrics/CyclomaticComplexity:
|
|||
# Offense count: 2
|
||||
Metrics/PerceivedComplexity:
|
||||
Max: 8
|
||||
|
||||
# Offense count: 1
|
||||
Style/AccessorMethodName:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 10
|
||||
Style/Documentation:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: MinBodyLength.
|
||||
Style/GuardClause:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
|
||||
# SupportedStyles: skip_modifier_ifs, always
|
||||
Style/Next:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 3
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
|
||||
# SupportedStyles: slashes, percent_r, mixed
|
||||
Style/RegexpLiteral:
|
||||
Enabled: false
|
||||
|
|
|
@ -28,7 +28,7 @@ module GitHubChangelogGenerator
|
|||
def run
|
||||
log = @generator.compound_changelog
|
||||
|
||||
output_filename = "#{@options[:output]}"
|
||||
output_filename = (@options[:output]).to_s
|
||||
File.open(output_filename, "w") { |file| file.write(log) }
|
||||
puts "Done!"
|
||||
puts "Generated log placed in #{Dir.pwd}/#{output_filename}"
|
||||
|
|
|
@ -123,12 +123,12 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow
|
|||
def fetch_closed_pull_requests
|
||||
pull_requests = []
|
||||
begin
|
||||
if @options[:release_branch].nil?
|
||||
response = @github.pull_requests.list @options[:user],
|
||||
response = if @options[:release_branch].nil?
|
||||
@github.pull_requests.list @options[:user],
|
||||
@options[:project],
|
||||
state: "closed"
|
||||
else
|
||||
response = @github.pull_requests.list @options[:user],
|
||||
@github.pull_requests.list @options[:user],
|
||||
@options[:project],
|
||||
state: "closed",
|
||||
base: @options[:release_branch]
|
||||
|
|
|
@ -12,10 +12,10 @@ module GitHubChangelogGenerator
|
|||
log += @options[:frontmatter] if @options[:frontmatter]
|
||||
log += "#{@options[:header]}\n\n"
|
||||
|
||||
if @options[:unreleased_only]
|
||||
log += generate_log_between_tags(filtered_tags[0], nil)
|
||||
log += if @options[:unreleased_only]
|
||||
generate_log_between_tags(filtered_tags[0], nil)
|
||||
else
|
||||
log += generate_log_for_all_tags
|
||||
generate_log_for_all_tags
|
||||
end
|
||||
|
||||
log += File.read(@options[:base]) if File.file?(@options[:base])
|
||||
|
@ -39,10 +39,10 @@ module GitHubChangelogGenerator
|
|||
index2 = hash[tag2]
|
||||
log += generate_log_between_tags(all_tags[index1], all_tags[index2])
|
||||
else
|
||||
fail ChangelogGeneratorError, "Can't find tag #{tag2} -> exit".red
|
||||
raise ChangelogGeneratorError, "Can't find tag #{tag2} -> exit".red
|
||||
end
|
||||
else
|
||||
fail ChangelogGeneratorError, "Can't find tag #{tag1} -> exit".red
|
||||
raise ChangelogGeneratorError, "Can't find tag #{tag1} -> exit".red
|
||||
end
|
||||
log
|
||||
end
|
||||
|
@ -79,15 +79,15 @@ module GitHubChangelogGenerator
|
|||
time_string = newer_tag_time.strftime @options[:date_format]
|
||||
|
||||
# Generate tag name and link
|
||||
if @options[:release_url]
|
||||
release_url = format(@options[:release_url], newer_tag_link)
|
||||
release_url = if @options[:release_url]
|
||||
format(@options[:release_url], newer_tag_link)
|
||||
else
|
||||
release_url = "#{project_url}/tree/#{newer_tag_link}"
|
||||
"#{project_url}/tree/#{newer_tag_link}"
|
||||
end
|
||||
if newer_tag_name.equal? @options[:unreleased_label]
|
||||
log += "## [#{newer_tag_name}](#{release_url})\n\n"
|
||||
log += if newer_tag_name.equal? @options[:unreleased_label]
|
||||
"## [#{newer_tag_name}](#{release_url})\n\n"
|
||||
else
|
||||
log += "## [#{newer_tag_name}](#{release_url}) (#{time_string})\n"
|
||||
"## [#{newer_tag_name}](#{release_url}) (#{time_string})\n"
|
||||
end
|
||||
|
||||
if @options[:compare_link] && older_tag_link
|
||||
|
@ -171,10 +171,10 @@ module GitHubChangelogGenerator
|
|||
|
||||
unless issue.pull_request.nil?
|
||||
if @options[:author]
|
||||
if issue.user.nil?
|
||||
title_with_number += " ({Null user})"
|
||||
title_with_number += if issue.user.nil?
|
||||
" ({Null user})"
|
||||
else
|
||||
title_with_number += " ([#{issue.user.login}](#{issue.user.html_url}))"
|
||||
" ([#{issue.user.login}](#{issue.user.html_url}))"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ module GitHubChangelogGenerator
|
|||
unless @options[:exclude_labels].nil?
|
||||
issues = issues.select do |issue|
|
||||
var = issue.labels.map(&:name) & @options[:exclude_labels]
|
||||
!(var).any?
|
||||
!var.any?
|
||||
end
|
||||
end
|
||||
issues
|
||||
|
@ -83,7 +83,7 @@ module GitHubChangelogGenerator
|
|||
|
||||
tag_in_range_new = tag_older_new_tag?(newer_tag_time, time)
|
||||
|
||||
tag_in_range = (tag_in_range_old) && (tag_in_range_new)
|
||||
tag_in_range = tag_in_range_old && tag_in_range_new
|
||||
|
||||
tag_in_range
|
||||
else
|
||||
|
@ -93,19 +93,19 @@ module GitHubChangelogGenerator
|
|||
end
|
||||
|
||||
def tag_older_new_tag?(newer_tag_time, time)
|
||||
if newer_tag_time.nil?
|
||||
tag_in_range_new = true
|
||||
tag_in_range_new = if newer_tag_time.nil?
|
||||
true
|
||||
else
|
||||
tag_in_range_new = time <= newer_tag_time
|
||||
time <= newer_tag_time
|
||||
end
|
||||
tag_in_range_new
|
||||
end
|
||||
|
||||
def tag_newer_old_tag?(older_tag_time, t)
|
||||
if older_tag_time.nil?
|
||||
tag_in_range_old = true
|
||||
tag_in_range_old = if older_tag_time.nil?
|
||||
true
|
||||
else
|
||||
tag_in_range_old = t > older_tag_time
|
||||
t > older_tag_time
|
||||
end
|
||||
tag_in_range_old
|
||||
end
|
||||
|
@ -133,7 +133,7 @@ module GitHubChangelogGenerator
|
|||
def filter_by_include_labels(issues)
|
||||
filtered_issues = @options[:include_labels].nil? ? issues : issues.select do |issue|
|
||||
labels = issue.labels.map(&:name) & @options[:include_labels]
|
||||
(labels).any?
|
||||
labels.any?
|
||||
end
|
||||
filtered_issues
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@ module GitHubChangelogGenerator
|
|||
# @param [Hash] tag_name name of the tag
|
||||
# @return [Time] time of specified tag
|
||||
def get_time_of_tag(tag_name)
|
||||
fail ChangelogGeneratorError, "tag_name is nil".red if tag_name.nil?
|
||||
raise ChangelogGeneratorError, "tag_name is nil".red if tag_name.nil?
|
||||
|
||||
name_of_tag = tag_name["name"]
|
||||
time_for_name = @tag_times_hash[name_of_tag]
|
||||
|
@ -80,10 +80,10 @@ module GitHubChangelogGenerator
|
|||
if tag
|
||||
if all_tags.map(&:name).include? tag
|
||||
idx = all_tags.index { |t| t.name == tag }
|
||||
if idx > 0
|
||||
filtered_tags = all_tags[0..idx - 1]
|
||||
filtered_tags = if idx > 0
|
||||
all_tags[0..idx - 1]
|
||||
else
|
||||
filtered_tags = []
|
||||
[]
|
||||
end
|
||||
else
|
||||
Helper.log.warn "Warning: can't find tag #{tag}, specified with --since-tag option."
|
||||
|
@ -101,10 +101,10 @@ module GitHubChangelogGenerator
|
|||
if (all_tags.count > 0) && (all_tags.map(&:name).include? tag)
|
||||
idx = all_tags.index { |t| t.name == tag }
|
||||
last_index = all_tags.count - 1
|
||||
if idx > 0 && idx < last_index
|
||||
filtered_tags = all_tags[idx + 1..last_index]
|
||||
filtered_tags = if idx > 0 && idx < last_index
|
||||
all_tags[idx + 1..last_index]
|
||||
else
|
||||
filtered_tags = []
|
||||
[]
|
||||
end
|
||||
else
|
||||
Helper.log.warn "Warning: can't find tag #{tag}, specified with --due-tag option."
|
||||
|
|
|
@ -6,10 +6,10 @@ module GitHubChangelogGenerator
|
|||
defined? SpecHelper
|
||||
end
|
||||
|
||||
if test?
|
||||
@log ||= Logger.new(nil) # don't show any logs when running tests
|
||||
@log ||= if test?
|
||||
Logger.new(nil) # don't show any logs when running tests
|
||||
else
|
||||
@log ||= Logger.new(STDOUT)
|
||||
Logger.new(STDOUT)
|
||||
end
|
||||
@log.formatter = proc do |severity, _datetime, _progname, msg|
|
||||
string = "#{msg}\n"
|
||||
|
|
|
@ -20,8 +20,8 @@ module GitHubChangelogGenerator
|
|||
|
||||
def parse_line!(line)
|
||||
key_sym, value = extract_pair(line)
|
||||
value = true if value =~ (/^(true|t|yes|y|1)$/i)
|
||||
value = false if value =~ (/^(false|f|no|n|0)$/i)
|
||||
value = true if value =~ /^(true|t|yes|y|1)$/i
|
||||
value = false if value =~ /^(false|f|no|n|0)$/i
|
||||
@options[key_sym] = value
|
||||
rescue
|
||||
raise ParserError, "Config file #{file} is incorrect in line \"#{line.gsub(/[\n\r]+/, '')}\""
|
||||
|
|
|
@ -37,7 +37,7 @@ module GitHubChangelogGenerator
|
|||
def define(args, &task_block)
|
||||
desc "Generate a Change log from GitHub"
|
||||
|
||||
task_block.call(*[self, args].slice(0, task_block.arity)) if task_block
|
||||
yield(*[self, args].slice(0, task_block.arity)) if task_block
|
||||
|
||||
# clear any (auto-)pre-existing task
|
||||
Rake::Task[@name].clear if Rake::Task.task_defined?(@name)
|
||||
|
@ -57,7 +57,7 @@ module GitHubChangelogGenerator
|
|||
|
||||
log = generator.compound_changelog
|
||||
|
||||
output_filename = "#{options[:output]}"
|
||||
output_filename = (options[:output]).to_s
|
||||
File.open(output_filename, "w") { |file| file.write(log) }
|
||||
puts "Done!"
|
||||
puts "Generated log placed in #{Dir.pwd}/#{output_filename}"
|
||||
|
|
Loading…
Reference in New Issue
Block a user