Skip to content

Commit

Permalink
#81 paranoia
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Aug 22, 2024
1 parent 1049d05 commit ba8bdab
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion assets/bylaws/bad-branch-name-was-punished.liquid
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(award
(explain "If a branch has a name that doesn\\\'t obey the convention, a penalty is given to the author")
(aka
(let fee -12)
(let fee {{ -6 | times: anger }})
(give fee "as a basis")
"deduct ${fee} points")
)
8 changes: 4 additions & 4 deletions assets/bylaws/code-contribution-was-rewarded.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

(aka
(let hoc_k {{ 0.05 | times: love }})
(let hoc_threshold 200)
(let hoc_threshold {{ 400 | divided_by: paranoia }})
(let hoc_max 16)
(let hoc_min 5)
(set bonus_for_hoc (if (lt hoc hoc_threshold) (times hoc hoc_k) 0))
Expand All @@ -30,7 +30,7 @@

(aka
(let many_hoc_fee2 {{ 8 | times: anger }})
(let hoc_threshold2 800)
(let hoc_threshold2 {{ 1600 | divided_by: paranoia }})
(set penalty_for_hoc2 (if (gte hoc hoc_threshold2) (times -1 many_hoc_fee2) 0))
(give penalty_for_hoc2 "for way too many hits-of-code (${hoc} >= ${hoc_threshold2})")
"deduct ${many_hoc_fee2} points if more than ${hoc_threshold2}
Expand All @@ -53,7 +53,7 @@

(aka
(let few_comments_fee {{ 2 | times: anger }})
(let comments_needed 5)
(let comments_needed {{ 3 | times: paranoia }})
(set penalty_for_few_comments (if (and (lt comments comments_needed) (not (eq comments 0))) (times -1 few_comments_fee) 0))
(give penalty_for_few_comments "for very few (${comments}) comments")
"deduct ${few_comments_fee} points if there were less than ${comments_needed} comments made during review")
Expand All @@ -66,7 +66,7 @@

(aka
(let few_hoc_fee {{ 4 | times: anger }})
(let hoc_needed 20)
(let hoc_needed {{ 10 | times: paranoia }})
(set penalty_for_few_hoc (if (lt hoc hoc_needed) (times -1 few_hoc_fee) 0))
(give penalty_for_few_hoc "for too few (${hoc}) hits-of-code")
"deduct ${few_hoc_fee} points if you contribute less than ${hoc_needed} hits-of-code")
Expand Down
4 changes: 2 additions & 2 deletions assets/bylaws/code-review-was-rewarded.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

(aka
(let few_comments_fee {{ 5 | times: anger }})
(let comments_needed 6)
(let comments_needed {{ 3 | times: paranoia }})
(set penalty_for_few_comments (if (and (lt comments comments_needed) (not (eq comments 0))) (times -1 few_comments_fee) 0))
(give penalty_for_few_comments "for very few (${comments}) comments")
"deduct ${few_comments_fee} points if there were less than ${comments_needed} comments made during review")
Expand All @@ -52,7 +52,7 @@

(aka
(let hoc_fee {{ 4 | times: anger }})
(let hoc_needed 15)
(let hoc_needed {{ 8 | times: paranoia }})
(set penalty_for_hoc (if (lt hoc hoc_needed) (times -1 hoc_fee) 0))
(give penalty_for_hoc "for too few (${hoc}) hits-of-code")
"deduct ${hoc_fee} points if there were less than ${hoc_needed} hits-of-code")
Expand Down
2 changes: 1 addition & 1 deletion assets/bylaws/push-to-master-was-punished.liquid
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(award
(explain "When someone pushes directly to the default branch, they get a penalty")
(aka
(let fee -16)
(let fee {{ -8 | times: anger }})
(give fee "as a basis")
"${fee} points")
)
2 changes: 1 addition & 1 deletion assets/bylaws/resolved-bug-was-rewarded.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

(aka
(let b1 {{ 4 | times: love }})
(let hours_threshold 24)
(let hours_threshold {{ 48 | divided_by: paranoia }})
(set b1 (if (lt hours hours_threshold) b1 0))
(give b1 "for resolving it in less than ${hours_threshold} hours")
"add ${b1} points if it was resolved in less than ${hours_threshold} hours")
Expand Down
4 changes: 2 additions & 2 deletions lib/fbe/bylaws.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
# Author:: Yegor Bugayenko ([email protected])
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
# License:: MIT
def Fbe.bylaws(anger: 2, love: 2)
def Fbe.bylaws(anger: 2, love: 2, paranoia: 2)
home = File.join(__dir__, '../../assets/bylaws')
raise "The directory with templates is absent '#{home}'" unless File.exist?(home)
Dir[File.join(home, '*.liquid')].to_h do |f|
formula = Liquid::Template.parse(File.read(f)).render(
'anger' => anger, 'love' => love
'anger' => anger, 'love' => love, 'paranoia' => paranoia
)
[File.basename(f).gsub(/\.liquid$/, ''), formula]
end
Expand Down
4 changes: 2 additions & 2 deletions test/fbe/test_bylaws.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_check_all_bills
{ hoc: 50, comments: 15, reviews: 0 } => 5,
{ hoc: 50, comments: 25, reviews: 0 } => 4,
{ hoc: 180, comments: 7, reviews: 2 } => 32,
{ hoc: 150, comments: 5, reviews: 1 } => 31,
{ hoc: 150, comments: 5, reviews: 1 } => 27,
{ hoc: 500, comments: 25, reviews: 2 } => 4,
{ hoc: 99, comments: 6, reviews: 1 } => 26,
{ hoc: 1_500, comments: 3, reviews: 0 } => 4,
Expand All @@ -104,7 +104,7 @@ def test_check_all_bills
assert(!formula.nil?, title)
a = Fbe::Award.new(formula)
help = [
" #{title}: {\n ",
" '#{title.gsub('-', '_')}' => {\n ",
pairs.map do |args, _|
[
'{',
Expand Down

0 comments on commit ba8bdab

Please sign in to comment.