The Case of the Missing Contribution
I love using Rubocop, not only is it great way to keep things clean, I contributed to the code base.
This was the pull request I made:
.to eq(['Assignment Branch Condition size for method_name is too ' \
- 'high. [6.4/0]']) # sqrt(1*1 + 5*5 + 2*2) => 6.4
+ 'high. [6.4/0]']) # sqrt(1*1 + 6*6 + 2*2) => 6.4But, when I look the change in the current file, I only see:
50 it 'registers an offense for complex content including A, B, and C ' \
51 'scores' do
52 expect_offense(<<-RUBY.strip_indent)
53 def method_name
54 ^^^^^^^^^^^^^^^ Assignment Branch Condition size for method_name is too high. [6.4/0]
55 my_options = Hash.new if 1 == 1 || 2 == 2 # 1, 3, 2
56 my_options.each do |key, value| # 0, 1, 0
57 p key # 0, 1, 0
58 p value # 0, 1, 0
59 end
60 end
61 RUBY
62 endWhat happened to my contribution??
git blame view
Well, if we look at the section with git blame, this is what we see:
e38f5551db (Jonas Arvidsson 2014-10-18 00:51:39 +0200 50) it 'registers an offense for complex content including A, B, and C ' \
e38f5551db (Jonas Arvidsson 2014-10-18 00:51:39 +0200 51) 'scores' do
aab0516dd3 (Ted Johansson 2018-06-09 23:58:19 +0800 52) expect_offense(<<-RUBY.strip_indent)
3c71da31aa (Yuji Nakayama 2017-04-09 19:23:08 +0900 53) def method_name
aab0516dd3 (Ted Johansson 2018-06-09 23:58:19 +0800 54) ^^^^^^^^^^^^^^^ Assignment Branch Condition size for method_name is too high. [6.4/0]
3c71da31aa (Yuji Nakayama 2017-04-09 19:23:08 +0900 55) my_options = Hash.new if 1 == 1 || 2 == 2 # 1, 3, 2
3c71da31aa (Yuji Nakayama 2017-04-09 19:23:08 +0900 56) my_options.each do |key, value| # 0, 1, 0
3c71da31aa (Yuji Nakayama 2017-04-09 19:23:08 +0900 57) p key # 0, 1, 0
3c71da31aa (Yuji Nakayama 2017-04-09 19:23:08 +0900 58) p value # 0, 1, 0
3c71da31aa (Yuji Nakayama 2017-04-09 19:23:08 +0900 59) end
3c71da31aa (Yuji Nakayama 2017-04-09 19:23:08 +0900 60) end
8f37b7f2f0 (Ted Johansson 2017-06-05 16:30:15 +0800 61) RUBY
d2ba8bf5f3 (savef 2016-10-07 23:48:33 +0100 62) endYup, my commit is definitely not there. :-(
git log message
I wonder what happened to it? Let’s look up the commit git blame
references in git log
$ git log 3c71da31aa37282281785a09dfa3ae234bae0fcb
commit 3c71da31aa37282281785a09dfa3ae234bae0fcb
Author: Yuji Nakayama <nkymyj@gmail.com>
Date: Sun Apr 9 19:23:08 2017 +0900
Use here-document for example sources in specs for readability
The array-of-lines style is hard to read. It's usable only when there're
trailing whitespaces in the example source.
Standard
--------
The following source:
```
source = [
'def some_method',
' body',
'end'
]
END
```
... should be converted to:
```
source = <<-END.strip_indent
def some_method
body
end
END
```
With indentations
-----------------
The following source:
```
source = [
' def some_method',
' body',
' end'
]
END
```
... should be converted to:
```
source = <<-END.strip_margin('|')
| def some_method
| body
| end
END
```
With trailing whitespaces
-------------------------
The following source does _not_ need to be converted:
```
source = [
'def some_method',
' body ',
'end'
]
END
```Welp - being an open source contributor was short as a re-write took out my contribution.
git log -S to the Rescue??
I learned recently from this Ruby talk
about git log -S, which is more powerful than git blame as it
tracks code over history, not just commit messages.
Let’s see what git log -S shows in this case when I focus on my main
contribution: 6*6:
$ git log -S 6*6
commit aab0516dd34247aed2588254690b5639524684ca
Author: Ted Johansson <drenmi@gmail.com>
Date: Sat Jun 9 23:58:19 2018 +0800
Improve usage of offense matchers and heredocs in specs
commit 2ce51e117380881004ed13fced1106a768d2d4f7
Author: Andrew Leung <andrew@ualberta.net>
Date: Sun Jan 29 22:07:17 2017 -0500
Fix documentation example for ABC Size (#3985)
The given code example has an ABC size of 6.4, but comments list the
calculation as:
Math.sqrt(1*1 + 5*5 + 2*2)
which results in: 5.48.
The correct calculation for the given the example are:
Math.sqrt(1*1 + 6*6 + 2*2) = 6.40
commit d55f91aea13f7b122ab19dd4606abd3306daac3b
Author: Bozhidar Batsov <bozhidar@tradeo.com>
Date: Thu Sep 4 18:57:44 2014 +0300
[Fix #578] Add a logoOh - interesting, my commit still appears in the history, yes! So that
means I am still contributor. Thank you git log -S!