refacktoring. move separation logic in funciton

This commit is contained in:
Petr Korolev 2015-05-22 13:34:01 +03:00
parent 3fc3e3e143
commit 944adc92cd
2 changed files with 49 additions and 35 deletions

View File

@ -1,13 +1,13 @@
# This configuration was generated by `rubocop --auto-gen-config`
# on 2015-05-14 16:51:06 +0300 using RuboCop version 0.31.0.
# on 2015-05-22 13:30:52 +0300 using RuboCop version 0.31.0.
# 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: 15
# Offense count: 17
Metrics/AbcSize:
Enabled: false
Max: 73
# Offense count: 2
Metrics/BlockNesting:
@ -16,16 +16,16 @@ Metrics/BlockNesting:
# Offense count: 3
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 337
Max: 345
# Offense count: 5
Metrics/CyclomaticComplexity:
Max: 15
# Offense count: 22
# Offense count: 24
# Configuration parameters: CountComments.
Metrics/MethodLength:
Enabled: false
Max: 121
# Offense count: 5
Metrics/PerceivedComplexity:
@ -41,7 +41,7 @@ Style/AccessorMethodName:
Style/AndOr:
Enabled: false
# Offense count: 19
# Offense count: 18
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
Style/BlockDelimiters:
@ -51,12 +51,12 @@ Style/BlockDelimiters:
Style/Documentation:
Enabled: false
# Offense count: 5
# Offense count: 3
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Enabled: false
# Offense count: 15
# Offense count: 14
# Cop supports --auto-correct.
# Configuration parameters: MaxLineLength.
Style/IfUnlessModifier:

View File

@ -161,12 +161,15 @@ module GitHubChangelogGenerator
# @param [Array] issues to filter
# @return [Array] filtered array of issues
def include_issues_by_labels(issues)
filtered_issues = @options[:include_labels].nil? ? issues : issues.select { |issue| (issue.labels.map(&:name) & @options[:include_labels]).any? }
filtered_issues = @options[:include_labels].nil? ? issues : issues.select do |issue|
labels = issue.labels.map(&:name) & @options[:include_labels]
(labels).any?
end
if @options[:add_issues_wo_labels]
issues_wo_labels = issues.select { |issue|
issues_wo_labels = issues.select do |issue|
!issue.labels.map(&:name).any?
}
end
filtered_issues |= issues_wo_labels
end
filtered_issues
@ -178,7 +181,8 @@ module GitHubChangelogGenerator
def exclude_issues_by_labels(issues)
unless @options[:exclude_labels].nil?
issues = issues.select { |issue|
!(issue.labels.map(&:name) & @options[:exclude_labels]).any?
var = issue.labels.map(&:name) & @options[:exclude_labels]
!(var).any?
}
end
issues
@ -405,6 +409,27 @@ module GitHubChangelogGenerator
if @options[:issues]
# Generate issues:
bugs_a, enhancement_a, issues_a = parse_by_sections(issues)
log += generate_sub_section(enhancement_a, @options[:enhancement_prefix])
log += generate_sub_section(bugs_a, @options[:bug_prefix])
log += generate_sub_section(issues_a, @options[:issue_prefix])
end
if @options[:pulls]
# Generate pull requests:
log += generate_sub_section(pull_requests, @options[:merge_prefix])
end
log
end
# This method sort issues by types
# (bugs, features, or just closed issues) by labels
#
# @param [Array] issues
# @return [Array] tuple of filtered arrays: (Bugs, Enhancements Issues)
def parse_by_sections(issues)
issues_a = []
enhancement_a = []
bugs_a = []
@ -427,18 +452,7 @@ module GitHubChangelogGenerator
issues_a.push dict
end
}
log += generate_sub_section(enhancement_a, @options[:enhancement_prefix])
log += generate_sub_section(bugs_a, @options[:bug_prefix])
log += generate_sub_section(issues_a, @options[:issue_prefix])
end
if @options[:pulls]
# Generate pull requests:
log += generate_sub_section(pull_requests, @options[:merge_prefix])
end
log
[bugs_a, enhancement_a, issues_a]
end
# @param [Array] issues List of issues on sub-section