Skip to content

Commit 3f89c06

Browse files
committed
cleanup rubocop and add pandoc to gh test action
1 parent c414132 commit 3f89c06

File tree

9 files changed

+69
-20
lines changed

9 files changed

+69
-20
lines changed

.github/workflows/main.yml

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ jobs:
1111
- uses: actions/checkout@v3
1212
# - name: Set up Redis
1313
# uses: zhulik/redis-action@1.1.0
14+
- name: Set up Pandoc
15+
uses: siacodelabs/setup-pandoc@v1
1416
- name: Install Ruby and gems
1517
uses: ruby/setup-ruby@v1
1618
with:

.rubocop.yml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
inherit_from: .rubocop_todo.yml
2+
13
require:
24
- rubocop-rake
35
- rubocop-rspec

.rubocop_todo.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# This configuration was generated by
2+
# `rubocop --auto-gen-config`
3+
# on 2024-03-03 10:06:52 UTC using RuboCop version 1.60.2.
4+
# The point is for the user to remove these configuration records
5+
# one by one as the offenses are removed from the code base.
6+
# Note that changes in the inspected code, or installation of new
7+
# versions of RuboCop, may require this file to be generated again.
8+
9+
# Offense count: 1
10+
# Configuration parameters: AllowedMethods, AllowedPatterns.
11+
Lint/NestedMethodDefinition:
12+
Exclude:
13+
- 'lib/caramelize/filters/textile_to_markdown.rb'
14+
15+
# Offense count: 2
16+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
17+
Metrics/AbcSize:
18+
Max: 79
19+
20+
# Offense count: 1
21+
# Configuration parameters: CountComments, CountAsOne.
22+
Metrics/ClassLength:
23+
Max: 118
24+
25+
# Offense count: 1
26+
# Configuration parameters: AllowedMethods, AllowedPatterns.
27+
Metrics/CyclomaticComplexity:
28+
Max: 9
29+
30+
# Offense count: 2
31+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
32+
Metrics/MethodLength:
33+
Max: 102
34+
35+
# Offense count: 1
36+
# Configuration parameters: AllowedMethods, AllowedPatterns.
37+
Metrics/PerceivedComplexity:
38+
Max: 9
39+
40+
# Offense count: 2
41+
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
42+
# Include: **/*_spec*rb*, **/spec/**/*
43+
RSpec/FilePath:
44+
Exclude:
45+
- 'spec/lib/caramelize/filters/add_newline_to_page_end_spec.rb'
46+
- 'spec/lib/caramelize/filters/mediawiki_to_markdown_spec.rb'
47+
48+
# Offense count: 2
49+
# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
50+
# Include: **/*_spec.rb
51+
RSpec/SpecFilePathFormat:
52+
Exclude:
53+
- '**/spec/routing/**/*'
54+
- 'spec/lib/caramelize/filters/add_newline_to_page_end_spec.rb'
55+
- 'spec/lib/caramelize/filters/mediawiki_to_markdown_spec.rb'

lib/caramelize/caramel.rb

+2-6
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
# not supported by default in this software
1010

1111
# Note, if you want to activate this, you need to uncomment the line below.
12-
# rubocop:todo Metrics/MethodLength
13-
def customized_wiki # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
12+
def customized_wiki
1413
# This example is a reimplementation of the WikkaWiki-Connector.
1514
# To connect to WikkaWiki, I suggest to use the predefined Connector below.
1615
options = { host: 'localhost',
@@ -20,8 +19,7 @@ def customized_wiki # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
2019
markup: :wikka }
2120
wiki = Caramelize::InputWiki::Wiki.new(options)
2221
wiki.instance_eval do
23-
# rubocop:todo Metrics/MethodLength
24-
def read_pages # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
22+
def read_pages
2523
sql = 'SELECT id, tag, body, time, latest, user, note FROM wikka_pages ORDER BY time;'
2624
results = database.query(sql)
2725
results.each do |row|
@@ -41,12 +39,10 @@ def read_pages # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
4139
titles.uniq!
4240
revisions
4341
end
44-
# rubocop:enable Metrics/MethodLength
4542
end
4643

4744
wiki
4845
end
49-
# rubocop:enable Metrics/MethodLength
5046

5147
# if you want to use one of the preset Wiki-Connectors uncomment the connector
5248
# and edit the database logins accordingly.

lib/caramelize/content_transferer.rb

+3-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module Caramelize
1010
require 'caramelize/input_wiki/redmine_wiki'
1111
require 'caramelize/input_wiki/wikka_wiki'
1212

13-
class ContentTransferer # rubocop:todo Metrics/ClassLength
13+
class ContentTransferer
1414
attr_reader :input_wiki, :options
1515

1616
DEFAULT_GOLLUM_HOME_TITLE = 'Home'
@@ -94,8 +94,7 @@ def commit_history_progress_bar
9494
total: revisions_count)
9595
end
9696

97-
# rubocop:todo Metrics/MethodLength
98-
def migrate_markup_of_latest_revisions # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
97+
def migrate_markup_of_latest_revisions
9998
puts 'Convert latest revisions:' if verbose?
10099
input_wiki.latest_revisions.each do |revision|
101100
if input_wiki.excluded_pages.include?(revision.title)
@@ -112,10 +111,8 @@ def migrate_markup_of_latest_revisions # rubocop:todo Metrics/AbcSize, Metrics/M
112111
migrate_markup_of_revision(revision)
113112
end
114113
end
115-
# rubocop:enable Metrics/MethodLength
116114

117-
# rubocop:todo Metrics/MethodLength
118-
def commit_history # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
115+
def commit_history
119116
output_wiki.commit_history(revisions, options) do |page, index|
120117
if input_wiki.excluded_pages.include?(page.title)
121118
puts "Exclude Page: #{page.title}" if verbose?
@@ -129,7 +126,6 @@ def commit_history # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
129126
end
130127
end
131128
end
132-
# rubocop:enable Metrics/MethodLength
133129

134130
def migrate_markup_of_revision(revision)
135131
body_new = filter_processor.run(revision.body)

lib/caramelize/health_checks/orphaned_pages_check.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def check
1818

1919
private
2020

21-
def check_page(page) # rubocop:todo Metrics/MethodLength
21+
def check_page(page)
2222
0.tap do |available_count|
2323
page.intra_wiki_links.each do |intra_wiki_path|
2424
if page_paths.include?(intra_wiki_path)

lib/caramelize/input_wiki/media_wiki.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def pages
8585
@pages ||= database.query(pages_query)
8686
end
8787

88-
def build_properties(row) # rubocop:todo Metrics/MethodLength
88+
def build_properties(row)
8989
author = authors[row['actor_user']] || { name: 'Anonymous', email: 'anonymous@example.com' }
9090
{
9191
id: row['rev_id'],

lib/caramelize/input_wiki/redmine_wiki.rb

+2-4
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ def read_authors
4040

4141
private
4242

43-
# rubocop:todo Metrics/MethodLength
44-
def build_page(row_page) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
43+
def build_page(row_page)
4544
results_contents = database.query(single_page_query(row_page['id']))
4645

4746
wiki = wikis.select { |row| row['id'] == row_page['wiki_id'] }.first
@@ -61,7 +60,6 @@ def build_page(row_page) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
6160
revisions << page
6261
end
6362
end
64-
# rubocop:enable Metrics/MethodLength
6563

6664
def add_projects_as_namespaces
6765
projects.each do |row_project|
@@ -103,7 +101,7 @@ def wikis
103101
@wikis ||= database.query(wikis_query)
104102
end
105103

106-
def build_properties(title, row_content) # rubocop:todo Metrics/MethodLength
104+
def build_properties(title, row_content)
107105
author = authors.fetch(row_content['author_id'], nil)
108106
{
109107
id: row_content['id'],

lib/caramelize/input_wiki/wikka_wiki.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def pages
5656
@pages ||= database.query(pages_query)
5757
end
5858

59-
def build_properties(row) # rubocop:todo Metrics/MethodLength
59+
def build_properties(row)
6060
author = authors[row['user']]
6161
{
6262
id: row['id'],

0 commit comments

Comments
 (0)