Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

update rubocop #32

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ AllCops:
TargetRubyVersion: 3.1
SuggestExtensions: false


Style/Documentation:
Enabled: false
StyleGuide: http://relaxed.ruby.style/#styledocumentation
Expand Down
8 changes: 4 additions & 4 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-03-03 10:06:52 UTC using RuboCop version 1.60.2.
# on 2024-03-04 19:34:06 UTC using RuboCop version 1.61.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
Expand All @@ -12,12 +12,12 @@ Lint/NestedMethodDefinition:
Exclude:
- 'lib/caramelize/filters/textile_to_markdown.rb'

# Offense count: 2
# Offense count: 5
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 79

# Offense count: 1
# Offense count: 2
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 118
Expand All @@ -27,7 +27,7 @@ Metrics/ClassLength:
Metrics/CyclomaticComplexity:
Max: 9

# Offense count: 2
# Offense count: 10
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
Metrics/MethodLength:
Max: 102
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ GEM
rubocop-ast (>= 0.4.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
rubocop-rspec (2.27.0)
rubocop-rspec (2.27.1)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
Expand Down
68 changes: 39 additions & 29 deletions lib/caramelize/content_transferer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,52 +97,62 @@ def commit_history_progress_bar
def migrate_markup_of_latest_revisions
puts 'Convert latest revisions:' if verbose?
input_wiki.latest_revisions.each do |revision|
if input_wiki.excluded_pages.include?(revision.title)
puts "Exclude Page: #{revision.title}" if verbose?
next
end

if verbose?
puts "Filter source: #{revision.title} #{revision.time}"
else
migrate_markup_progress_bar.increment
end

migrate_markup_of_revision(revision)
convert_markup_of_revision(revision)
end
end

def commit_history
output_wiki.commit_history(revisions, options) do |page, index|
if input_wiki.excluded_pages.include?(page.title)
puts "Exclude Page: #{page.title}" if verbose?
next
end

if verbose?
puts "(#{index + 1}/#{revisions_count}) #{page.time} #{page.title}"
else
commit_history_progress_bar.increment
end
commit_page(page, index)
end
end

def migrate_markup_of_revision(revision)
def commit_page(page, index)
if input_wiki.excluded_pages.include?(page.title)
puts "Exclude Page: #{page.title}" if verbose?
return
end

if verbose?
puts "(#{index + 1}/#{revisions_count}) #{page.time} #{page.title}"
else
commit_history_progress_bar.increment
end
end

def run_filter_processor_on_revision(revision)
body_new = filter_processor.run(revision.body)

return if body_new == revision.body

message = "Markup of '#{revision.title}' converted to #{target_markup}"
revision.message = "Markup of '#{revision.title}' converted to #{target_markup}"

commit_as_latest_page(revision)
end

def convert_markup_of_revision(revision)
if input_wiki.excluded_pages.include?(revision.title)
puts "Exclude Page: #{revision.title}" if verbose?
return
end

if verbose?
puts "Filter source: #{revision.title} #{revision.time}"
else
migrate_markup_progress_bar.increment
end

run_filter_processor_on_revision(revision)
end

# commit as latest page revision
output_wiki.commit_revision(build_revision_metadata(revision, body_new, message), options[:markup])
def commit_as_latest_page(revision)
output_wiki.commit_revision(build_revision_metadata(revision, body_new), options[:markup])
end

def build_revision_metadata(revision, body_new, message)
def build_revision_metadata(revision, body_new)
revision.body = body_new
revision.author = { name: DEFAULT_AUTHOR_NAME, email: DEFAULT_AUTHOR_EMAIL }
revision.time = Time.now
revision.message = message
revision.time = Time.zone.now

revision
end
Expand Down
Loading