This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new a0e7914 Linting
a0e7914 is described below
commit a0e7914b784ea9ab249af205d987224006aaa6fb
Author: Sebb <[email protected]>
AuthorDate: Mon Mar 28 23:31:10 2022 +0100
Linting
---
lib/whimsy/asf/agenda/attachments.rb | 18 ++++++-------
lib/whimsy/asf/agenda/back.rb | 6 ++---
lib/whimsy/asf/agenda/committee.rb | 4 +--
lib/whimsy/asf/agenda/exec-officer.rb | 12 ++++-----
lib/whimsy/asf/agenda/special.rb | 34 ++++++++++++-------------
www/board/agenda/.rspec | 1 +
www/board/agenda/models/minutes.rb | 48 +++++++++++++++++------------------
www/board/agenda/spec/spec_helper.rb | 6 ++++-
8 files changed, 66 insertions(+), 63 deletions(-)
diff --git a/lib/whimsy/asf/agenda/attachments.rb
b/lib/whimsy/asf/agenda/attachments.rb
index c8fbccd..9512766 100644
--- a/lib/whimsy/asf/agenda/attachments.rb
+++ b/lib/whimsy/asf/agenda/attachments.rb
@@ -17,24 +17,24 @@ class ASF::Board::Agenda
attrs['title'] += ' ' + append.strip
end
- attrs['title'].sub! /^Report from the VP of /, ''
- attrs['title'].sub! /^Report from the /, ''
- attrs['title'].sub! /^Status report for the /, ''
- attrs['title'].sub! /^Apache /, ''
+ attrs['title'].sub! %r{^Report from the VP of }, ''
+ attrs['title'].sub! %r{^Report from the }, ''
+ attrs['title'].sub! %r{^Status report for the }, ''
+ attrs['title'].sub! %r{^Apache }, ''
attrs['title'].sub! 'Apache Software Foundation', 'ASF'
if attrs['title'] =~ /\s*\[.*\]$/
attrs['owner'] = attrs['title'][/\[(.*?)\]/, 1]
- attrs['title'].sub! /\s*\[.*\]$/, ''
+ attrs['title'].sub! %r{\s*\[.*\]$}, ''
end
- attrs['title'].sub! /\sTeam$/, ''
- attrs['title'].sub! /\sCommittee$/, ''
- attrs['title'].sub! /\sProject$/, ''
+ attrs['title'].sub! %r{\sTeam$}, ''
+ attrs['title'].sub! %r{\sCommittee$}, ''
+ attrs['title'].sub! %r{\sProject$}, ''
attrs['digest'] = Digest::MD5.hexdigest(attrs['report'].strip)
- attrs['report'].sub! /\n+\Z/, "\n"
+ attrs['report'].sub! %r{\n+\Z}, "\n"
attrs.delete('report') if attrs['report'] == "\n"
attrs['missing'] = true if attrs['report'].strip.empty?
diff --git a/lib/whimsy/asf/agenda/back.rb b/lib/whimsy/asf/agenda/back.rb
index efd49cc..f5b974d 100644
--- a/lib/whimsy/asf/agenda/back.rb
+++ b/lib/whimsy/asf/agenda/back.rb
@@ -16,7 +16,7 @@ class ASF::Board::Agenda
scan @file, pattern do |attrs|
attrs['attach'].strip!
- attrs['title'].sub! /^Review Outstanding /, ''
+ attrs['title'].sub! %r{^Review Outstanding }, ''
if attrs['title'] =~ /Discussion|Action|Business|Announcements/
attrs['prior_reports'] = minutes(attrs['title'])
@@ -28,8 +28,8 @@ class ASF::Board::Agenda
# extract action items associated with projects
text = attrs['text'].sub(/\A\s*\n/, '').sub(/\s+\Z/, '')
- unindent = text.sub(/s+\Z/,'').scan(/^ *\S/).map(&:length).min || 1
- text.gsub! /^ {#{unindent-1}}/, ''
+ unindent = text.sub(/s+\Z/, '').scan(/^ *\S/).map(&:length).min || 1
+ text.gsub! %r{^ {#{unindent - 1}}}, ''
attrs['missing'] = text.empty?
diff --git a/lib/whimsy/asf/agenda/committee.rb
b/lib/whimsy/asf/agenda/committee.rb
index d3a7bcf..5e7b9c9 100644
--- a/lib/whimsy/asf/agenda/committee.rb
+++ b/lib/whimsy/asf/agenda/committee.rb
@@ -13,8 +13,8 @@ class ASF::Board::Agenda
attrs['shepherd'] = attrs['owner'].split('/').last.strip
attrs['owner'] = attrs['owner'].split('/').first.strip
- attrs['comments'].gsub! /^ {1,10}(\w+:)/, '\1'
- attrs['comments'].gsub! /^ {11}/, ''
+ attrs['comments'].gsub! %r{^ {1,10}(\w+:)}, '\1'
+ attrs['comments'].gsub! %r{^ {11}}, ''
end
end
end
diff --git a/lib/whimsy/asf/agenda/exec-officer.rb
b/lib/whimsy/asf/agenda/exec-officer.rb
index 2706bb1..fbe5923 100644
--- a/lib/whimsy/asf/agenda/exec-officer.rb
+++ b/lib/whimsy/asf/agenda/exec-officer.rb
@@ -2,10 +2,10 @@
class ASF::Board::Agenda
parse do
- reports = @file.split(OFFICER_SEPARATOR,2).last
- a = reports.split(/^ 5. Additional Officer Reports/,2).first
- b = reports.split(/^ 5. Committee Reports/,2).first # Allow parsing of
pre-2007 reports
- (a.length > b.length) ? reports = b : reports = a
+ reports = @file.split(OFFICER_SEPARATOR, 2).last
+ a = reports.split(/^ 5. Additional Officer Reports/, 2).first
+ b = reports.split(/^ 5. Committee Reports/, 2).first # Allow parsing of
pre-2007 reports
+ a.length > b.length ? reports = b : reports = a
pattern = /
\s{4}(?<section>[A-Z])\.
@@ -20,9 +20,9 @@ class ASF::Board::Agenda
attrs['shepherd'] = attrs['owner'].split('/').last
attrs['owner'] = attrs['owner'].split('/').first
- attrs['report'].sub! /\A\s*\n/, ''
+ attrs['report'].sub! %r{/\A\s*\n}, ''
- attrs['report'].gsub! /\n\s*\n\s+\[ comments:(.*)\]\s*$/m do
+ attrs['report'].gsub! %r{\n\s*\n\s+\[ comments:(.*)\]\s*$}m do
attrs['comments'] = $1.sub(/\A\s*\n/, '').sub(/\s+\Z/, '')
"\n"
end
diff --git a/lib/whimsy/asf/agenda/special.rb b/lib/whimsy/asf/agenda/special.rb
index 7244371..71c3066 100644
--- a/lib/whimsy/asf/agenda/special.rb
+++ b/lib/whimsy/asf/agenda/special.rb
@@ -2,8 +2,8 @@
class ASF::Board::Agenda
parse do
- orders = @file.split(/^ \d. Special Orders/,2).last.
- split(/^ \d. Discussion Items/,2).first
+ orders = @file.split(/^ \d. Special Orders/, 2).last.
+ split(/^ \d. Discussion Items/, 2).first
pattern = /
\n+(?<indent>\s{3,5})(?<section>[A-Z])\.
@@ -19,18 +19,18 @@ class ASF::Board::Agenda
title = attrs['title']
title.strip!
fulltitle = title.dup
- title.sub! /^Resolution to /, ''
- title.sub! /\sthe\s/, ' '
- title.sub! /\sApache\s/, ' '
- title.sub! /\sCommittee\s/, ' '
- title.sub! /\sProject(\s|$)/i, '\1'
- title.sub! /\sPMC(\s|$)/, '\1'
+ title.sub! %r{^Resolution to }, ''
+ title.sub! %r{\sthe\s}, ' '
+ title.sub! %r{\sApache\s}, ' '
+ title.sub! %r{\sCommittee\s}, ' '
+ title.sub! %r{\sProject(\s|$)}i, '\1'
+ title.sub! %r{\sPMC(\s|$)}, '\1'
if title =~ /^Establish .* \((.*)\)$/
- title.sub! /\s.*?\(/, ' '
- title.sub! /\)$/, ''
+ title.sub! %r{\s.*?\(}, ' '
+ title.sub! %r{\)$}, ''
else
- title.sub! /\s\(.*\)$/, ''
+ title.sub! %r{\s\(.*\)$}, ''
end
attrs['fulltitle'] = fulltitle if title != fulltitle
@@ -42,7 +42,7 @@ class ASF::Board::Agenda
if attrs['indent'] != ' '
attrs['warnings'] << 'Heading is not indented 4 spaces'
end
- if text.sub(/s+\Z/,'').scan(/^ *\S/).map(&:length).min != 8
+ if text.sub(/s+\Z/, '').scan(/^ *\S/).map(&:length).min != 8
attrs['warnings'] << 'Resolution is not indented 7 spaces'
end
@@ -55,7 +55,6 @@ class ASF::Board::Agenda
title_checks.each do |select, match|
if fulltitle =~ select and fulltitle !~ match and
(fulltitle + text) =~ /chair|project|committee/i
- then
attrs['warnings'] <<
"Non-standard title wording: #{fulltitle.inspect}; " +
"expected #{match.inspect}"
@@ -117,11 +116,10 @@ class ASF::Board::Agenda
elsif title =~ /Establish (.*)/
name = $1
attrs['prior_reports'] =
- "#{whimsy}/board/minutes/#{name.gsub(/\W/,'_')}"
+ "#{whimsy}/board/minutes/#{name.gsub(/\W/, '_')}"
if text.scan(/[<(][-.\w]+@(?:[-\w]+\.)+\w+[>)]/).
any? {|email| not email.include? 'apache.org'}
- then
attrs['warnings'] << 'non apache.org email address found'
end
@@ -130,12 +128,12 @@ class ASF::Board::Agenda
# extract the committee charter
charters = []
text.scan(%r{\srelated to\s+(.+?)(?:;|\.?\n\n)}m) do |rto|
- charters << rto.first.gsub(/\s+/,' ')
+ charters << rto.first.gsub(/\s+/, ' ')
end
if charters.size != 2
attrs['warnings'] << "Expected 2 'related to' phrases; found
#{charters.size}"
elsif charters[0] != charters[1]
- attrs['warnings'] << "'related to' phrases disagree:
'#{charters[0]}' != '#{charters[1]}'"
+ attrs['warnings'] << "'related to' phrases disagree:
'#{charters[0]}' != '#{charters[1]}'"
end
attrs['charter'] = charters.first
@@ -148,7 +146,7 @@ class ASF::Board::Agenda
if chairname =~ /\s\(([-.\w]+)\)$/
# if chair's id is present in parens, use that value
attrs['chair'] = $1 unless $1.empty?
- chairname.sub! /\s+\(.*\)$/, ''
+ chairname.sub! %r{\s+\(.*\)$}, ''
else
# match chair's name against people in the committee
chair = people.find {|person| person.first == chairname}
diff --git a/www/board/agenda/.rspec b/www/board/agenda/.rspec
new file mode 100644
index 0000000..b45da65
--- /dev/null
+++ b/www/board/agenda/.rspec
@@ -0,0 +1 @@
+-w
\ No newline at end of file
diff --git a/www/board/agenda/models/minutes.rb
b/www/board/agenda/models/minutes.rb
index f80aa99..dc0b7c8 100755
--- a/www/board/agenda/models/minutes.rb
+++ b/www/board/agenda/models/minutes.rb
@@ -12,19 +12,19 @@ class Minutes
meeting.gsub! "soon thereafter that", "#{start} when"
meeting.gsub! "quorum is", "quorum was"
meeting.gsub! "will be", "was"
- meeting.gsub! /:\z/, "."
+ meeting.gsub! %r{:\z}, "."
backup.gsub! "will be", "was"
- [meeting.reflow(4,64), '', backup.reflow(4, 68)]
+ [meeting.reflow(4, 64), '', backup.reflow(4, 68)]
end
- minutes.sub! /^ +ASF members are welcome to attend board meetings.*?\n\n/m,
+ minutes.sub! %r{^ +ASF members are welcome to attend board
meetings.*?\n\n}m,
''
minutes.mreplace(/\n\s2\.\sRoll\sCall\n\n
(.*?)\n\n+\s3.\sMinutes
/mx) do |rollcall|
if notes('Roll Call')
- notes('Roll Call').gsub(/\r\n/,"\n").gsub(/\n*\Z/,'').
+ notes('Roll Call').gsub(/\r\n/, "\n").gsub(/\n*\Z/, '').
gsub(/^([^\n])/, ' \1')
else
rollcall.gsub(/ \(expected.*?\)/, '')
@@ -95,7 +95,7 @@ class Minutes
break if reports.empty?
reports.mreplace(/\n\s\s\s\s(\w)\.(.*?)\n(.*?)()\s+(?:\s*\n\s\s\s\s\w\.|\z)
/mx) do |section, title, order, comments|
- order.sub! /\n \[.*?\n +\]\n/m, ''
+ order.sub! %r{\n \[.*?\n +\]\n}m, ''
notes = notes(title.strip)
if !notes or notes.empty? or notes.strip == 'tabled'
notes = "was tabled."
@@ -115,7 +115,7 @@ class Minutes
break unless reports =~ /\n\s{3,5}[A-Z]\.\s/
reports.mreplace(/\n\s\s\s\s(\w)\.(.*?)\n(.*?)()\s+(?:\s*\n\s\s\s\s\w\.|\z)
/mx) do |section, title, item, comments|
- item.sub! /\n \[.*?\n +\]\n/m, ''
+ item.sub! %r{\n \[.*?\n +\]\n}m, ''
item += "\n" unless item =~ /\n\Z/
notes = notes(title.strip) || ''
[section, title, item, "\n" + notes.reflow(7,70)]
@@ -146,7 +146,7 @@ class Minutes
missing = minutes.scan(/^Attachment (\w\w?):.*\s*\n---/).flatten
missing.each do |attach|
- minutes.sub! /^(\s+)See Attachment #{Regexp.escape(attach)}$/, '\1No
report was submitted.'
+ minutes.sub! %r{^(\s+)See Attachment #{Regexp.escape(attach)}$}, '\1No
report was submitted.'
end
minutes.sub! 'Minutes (in Subversion) are found under the URL:',
@@ -169,18 +169,18 @@ class Minutes
" Committee reports approved as submitted by General Consent.\n\n"
minutes.sub! 'Meeting Agenda', 'Meeting Minutes'
- minutes.sub! /^End of agenda/, 'End of minutes'
+ minutes.sub! %r{^End of agenda}, 'End of minutes'
# remove block of lines (and preceding whitespace including blank lines)
# where the first line starts with <private> and the last line ends with
# </private>.
- minutes.gsub! /^\s*<private>.*?<\/private>\s*?\n/mi, ''
+ minutes.gsub! %r{^\s*<private>.*?<\/private>\s*?\n}mi, ''
# remove inline <private>...</private> sections (and preceding spaces
# and tabs) where the <private> and </private> are on the same line.
- minutes.gsub! /[ \t]*<private>.*?<\/private>/i, ''
+ minutes.gsub! %r{[ \t]*<private>.*?<\/private>}i, ''
- minutes.gsub! /\n( *)\[ comments:.*?\n\1 ? ?\]/m, ''
+ minutes.gsub! %r{\n( *)\[ comments:.*?\n\1 ? ?\]}m, ''
minutes
end
@@ -189,19 +189,19 @@ class Minutes
index = index.strip
return @@notes[index] if @@notes[index]
- index.sub! /^Report from the VP of /, ''
- index.sub! /^Report from the /, ''
- index.sub! /^Status report for the /, ''
- index.sub! /^Resolution to /, ''
- index.sub! /^Apache /, ''
- index.sub! /\sTeam$/, ''
- index.sub! /\sCommittee$/, ''
- index.sub! /\sthe\s/, ' '
- index.sub! /\sApache\s/, ' '
- index.sub! /\sCommittee\s/, ' '
- index.sub! /\sProject$/, ''
- index.sub! /\sPMC$/, ''
- index.sub! /\sProject\s/, ' '
+ index.sub! %r{^Report from the VP of }, ''
+ index.sub! %r{^Report from the }, ''
+ index.sub! %r{^Status report for the }, ''
+ index.sub! %r{^Resolution to }, ''
+ index.sub! %r{^Apache }, ''
+ index.sub! %r{\sTeam$}, ''
+ index.sub! %r{\sCommittee$}, ''
+ index.sub! %r{\sthe\s}, ' '
+ index.sub! %r{\sApache\s}, ' '
+ index.sub! %r{\sCommittee\s}, ' '
+ index.sub! %r{\sProject$}, ''
+ index.sub! %r{\sPMC$}, ''
+ index.sub! %r{\sProject\s}, ' '
@@notes[index]
end
diff --git a/www/board/agenda/spec/spec_helper.rb
b/www/board/agenda/spec/spec_helper.rb
index fa8ee6d..5f9d63e 100644
--- a/www/board/agenda/spec/spec_helper.rb
+++ b/www/board/agenda/spec/spec_helper.rb
@@ -27,10 +27,14 @@ module MockServer
Struct.new(:user, :password).new('test', nil)
end
+ def respond_to_missing?(method, _include_private=false)
+ method =~ /^_(\w+)$/
+ end
+
# capture wunderbar 'json' output methods
def method_missing(method, *args, &block)
if method =~ /^_(\w+)$/ and args.length == 1
- instance_variable_set "@#$1", args.first
+ instance_variable_set "@#{$1}", args.first
else
super
end