Skip to content

Commit

Permalink
Chore: Rubocop 0.49.0 (github-changelog-generator#516)
Browse files Browse the repository at this point in the history
* Rubocoping
  • Loading branch information
olleolleolle authored May 24, 2017
1 parent 26b124a commit 874c23c
Show file tree
Hide file tree
Showing 22 changed files with 132 additions and 116 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

source "https://rubygems.org"

ruby RUBY_VERSION
Expand Down
3 changes: 2 additions & 1 deletion github_changelog_generator.gemspec
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# coding: utf-8
# frozen_string_literal: true

lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "github_changelog_generator/version"
Expand All @@ -18,7 +19,7 @@ Gem::Specification.new do |spec|
spec.homepage = "https://github.com/skywinder/Github-Changelog-Generator"
spec.license = "MIT"

spec.files = Dir["{bin,lib,man,spec}/**/*"] + %w(LICENSE Rakefile README.md)
spec.files = Dir["{bin,lib,man,spec}/**/*"] + %w[LICENSE Rakefile README.md]

spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
Expand Down
22 changes: 9 additions & 13 deletions lib/github_changelog_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
require "multi_json"
require "benchmark"

require_relative "github_changelog_generator/helper"
require_relative "github_changelog_generator/options"
require_relative "github_changelog_generator/parser"
require_relative "github_changelog_generator/parser_file"
require_relative "github_changelog_generator/generator/generator"
require_relative "github_changelog_generator/version"
require_relative "github_changelog_generator/reader"
require "github_changelog_generator/helper"
require "github_changelog_generator/options"
require "github_changelog_generator/parser"
require "github_changelog_generator/parser_file"
require "github_changelog_generator/generator/generator"
require "github_changelog_generator/version"
require "github_changelog_generator/reader"

# The main module, where placed all classes (now, at least)
module GitHubChangelogGenerator
Expand All @@ -33,14 +33,10 @@ def initialize
def run
log = @generator.compound_changelog

output_filename = (@options[:output]).to_s
File.open(output_filename, "w") { |file| file.write(log) }
output_filename = @options[:output].to_s
File.open(output_filename, "wb") { |file| file.write(log) }
puts "Done!"
puts "Generated log placed in #{Dir.pwd}/#{output_filename}"
end
end

if __FILE__ == $PROGRAM_NAME
GitHubChangelogGenerator::ChangelogGenerator.new.run
end
end
1 change: 1 addition & 0 deletions lib/github_changelog_generator/generator/generator.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require_relative "../octo_fetcher"
require_relative "generator_generation"
require_relative "generator_fetcher"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module GitHubChangelogGenerator
class Generator
MAX_THREAD_NUMBER = 25
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module GitHubChangelogGenerator
class Generator
# Main function to start change log generation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module GitHubChangelogGenerator
class Generator
# delete all labels with labels from options[:exclude_labels] array
Expand Down Expand Up @@ -132,8 +133,8 @@ def include_issues_by_labels(issues)
# @return [Array] issues without labels or empty array if add_issues_wo_labels is false
def filter_wo_labels(issues)
if options[:add_issues_wo_labels]
issues_wo_labels = issues.select do |issue|
!issue["labels"].map { |l| l["name"] }.any?
issues_wo_labels = issues.reject do |issue|
issue["labels"].map { |l| l["name"] }.none?
end
return issues_wo_labels
end
Expand Down Expand Up @@ -197,8 +198,8 @@ def filter_merged_pull_requests(pull_requests)
end
end

pull_requests.select! do |pr|
!pr["merged_at"].nil?
pull_requests.reject! do |pr|
pr["merged_at"].nil?
end

pull_requests
Expand Down
1 change: 1 addition & 0 deletions lib/github_changelog_generator/generator/generator_tags.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module GitHubChangelogGenerator
class Generator
# fetch, filter tags, fetch dates and sort them in time order
Expand Down
1 change: 1 addition & 0 deletions lib/github_changelog_generator/helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require "logger"
require "rainbow"

Expand Down
95 changes: 48 additions & 47 deletions lib/github_changelog_generator/options.rb
Original file line number Diff line number Diff line change
@@ -1,56 +1,57 @@
# frozen_string_literal: true

require "delegate"
module GitHubChangelogGenerator
class Options < SimpleDelegator
UnsupportedOptionError = Class.new(ArgumentError)

KNOWN_OPTIONS = [
:add_issues_wo_labels,
:add_pr_wo_labels,
:author,
:base,
:between_tags,
:bug_labels,
:bug_prefix,
:cache_file,
:cache_log,
:compare_link,
:date_format,
:due_tag,
:enhancement_labels,
:enhancement_prefix,
:exclude_labels,
:exclude_tags,
:exclude_tags_regex,
:filter_issues_by_milestone,
:frontmatter,
:future_release,
:git_remote,
:github_endpoint,
:github_site,
:header,
:http_cache,
:include_labels,
:issue_prefix,
:issue_line_labels,
:issues,
:max_issues,
:merge_prefix,
:output,
:project,
:pulls,
:release_branch,
:release_url,
:simple_list,
:since_tag,
:ssl_ca_file,
:token,
:unreleased,
:unreleased_label,
:unreleased_only,
:user,
:usernames_as_github_logins,
:verbose
KNOWN_OPTIONS = %i[
add_issues_wo_labels
add_pr_wo_labels
author
base
between_tags
bug_labels
bug_prefix
cache_file
cache_log
compare_link
date_format
due_tag
enhancement_labels
enhancement_prefix
exclude_labels
exclude_tags
exclude_tags_regex
filter_issues_by_milestone
frontmatter
future_release
git_remote
github_endpoint
github_site
header
http_cache
include_labels
issue_prefix
issue_line_labels
issues
max_issues
merge_prefix
output
project
pulls
release_branch
release_url
simple_list
since_tag
ssl_ca_file
token
unreleased
unreleased_label
unreleased_only
user
usernames_as_github_logins
verbose
]

def initialize(values)
Expand Down
5 changes: 3 additions & 2 deletions lib/github_changelog_generator/parser_file.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require "pathname"

module GitHubChangelogGenerator
Expand Down Expand Up @@ -65,8 +66,8 @@ def extract_pair(line)
[key.tr("-", "_").to_sym, value.gsub(/[\n\r]+/, "")]
end

KNOWN_ARRAY_KEYS = [:exclude_labels, :include_labels, :bug_labels,
:enhancement_labels, :issue_line_labels, :between_tags, :exclude_tags]
KNOWN_ARRAY_KEYS = %i[exclude_labels include_labels bug_labels
enhancement_labels issue_line_labels between_tags exclude_tags]
KNOWN_INTEGER_KEYS = [:max_issues]

def convert_value(value, option_name)
Expand Down
1 change: 1 addition & 0 deletions lib/github_changelog_generator/reader.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

#
# Author:: Enrico Stahn <[email protected]>
#
Expand Down
5 changes: 3 additions & 2 deletions lib/github_changelog_generator/task.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require "rake"
require "rake/tasklib"
require "github_changelog_generator"
Expand All @@ -7,7 +8,7 @@ module GitHubChangelogGenerator
class RakeTask < ::Rake::TaskLib
include ::Rake::DSL if defined?(::Rake::DSL)

OPTIONS = %w( user project token date_format output
OPTIONS = %w[ user project token date_format output
bug_prefix enhancement_prefix issue_prefix
header merge_prefix issues
add_issues_wo_labels add_pr_wo_labels
Expand All @@ -18,7 +19,7 @@ class RakeTask < ::Rake::TaskLib
between_tags exclude_tags exclude_tags_regex since_tag max_issues
github_site github_endpoint simple_list
future_release release_branch verbose release_url
base )
base ]

OPTIONS.each do |o|
attr_accessor o.to_sym
Expand Down
1 change: 1 addition & 0 deletions lib/github_changelog_generator/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module GitHubChangelogGenerator
VERSION = "1.14.3"
end
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

#
# Author:: Enrico Stahn <[email protected]>
#
Expand Down
3 changes: 2 additions & 1 deletion spec/unit/generator/generator_processor_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

module GitHubChangelogGenerator
describe Generator do
context "#exclude_issues_by_labels" do
Expand All @@ -7,7 +8,7 @@ module GitHubChangelogGenerator
let(:good_label) { { "name" => "GOOD" } }
let(:good_issue) { { "labels" => [good_label] } }
let(:issues) { [issue, good_issue] }
subject(:generator) { described_class.new(exclude_labels: %w(BAD BOO)) }
subject(:generator) { described_class.new(exclude_labels: %w[BAD BOO]) }

it "removes issues with labels in the exclude_label list" do
result = generator.exclude_issues_by_labels(issues)
Expand Down
Loading

0 comments on commit 874c23c

Please sign in to comment.