-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add devtools #10
Add devtools #10
Conversation
* Make Yardstick::Processor simpler - Delegates work to parser and DocumentSet. * Add Yardstick::Parser - Talks directly with YARD, returns set of documents. * Add Yardstick::DocumentSet - Wrapper for documents.
@indrekj you can fix the timeout error on rbx by doing something like: https://github.com/snusnu/substation/blob/master/config/devtools.yml |
Build failed because (rbx-18):
https://github.com/indrekj/yardstick/blob/devtools/lib/yardstick/rake/verify.rb#L33 It seems a random error that doesn't happen every time. Any suggestions how to fix it? |
Oh, I was late :). Thanks. |
@@ -43,7 +43,7 @@ def initialize(options = {}, name = :yardstick_measure, &block) | |||
# | |||
# @api public | |||
def yardstick_measure | |||
write_report { |io| Yardstick.measure(@config).puts(io) } | |||
@config.output.write { |io| Yardstick.measure(@config).puts(io) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicking: You introduce a LOD violation with the remove of the #write_report
method below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@indrekj Sorry, for the noise. The removed method was only used once and also has LOD violation. Ignore this ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The LoD violation was in the write_report method before I moved it here. Do you think it would be better to move it to config? e.g @config.write_output {}
. Or is there a nicer way?
EDIT: oh, I have a lag or something. I didn't see your second message before writing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for this case it is just acceptable as is.
If there are multiple writes in this class I'd reintroduce that helper method with LOD-violation again. If @config.output
is accessed twice I'd add a special proxy method like: def output; @config.output; end
with private visibility.
IMHO LOD must be fixed if same navigation (sub) path is used more than once. If you only navigate once it depends on badness of more-loc vs LOD-violation.
Edit:
You could also "unpack" output to an instance variable in initializer.
Travis rbx-18mode failed with: Unit test took 0.10097199999999999 but max allowed is 0.1
end | ||
|
||
describe 'without a method summary when validations are turned off' do | ||
let(:config) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stylistic:
I'd use do
end
style for blocks spanning multiple lines.
let(:config) do
...
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm interested what is the correct convention here. I remember reading from IRC that blocks which return something should always use {}
. Not sure if it was just for discussion or an actual convention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i usually follow the convention you've mentioned rather strictly, therefore let
statements that use do ... end
look very weird to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dkubb I guess you repo, your rules. Is this ( https://github.com/dkubb/styleguide/blob/master/RUBY-STYLE#L55 ) up to date?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Travis jruby-19mode failed with: Unit test took 0.253 but max allowed is 0.2
There seems to be something wrong with Travis. I got |
@indrekj Its just statistic fluctuation. We just discussed this here: http://irclogger.com/.datamapper/2013-05-06#1367851643 IMHO we should pick 0.3 or something now and use a different strategy in future. |
@mbj tbh, imo everytime i have to adjust the timeout value to something i have no idea if it will pass or not, i'm just annoyed and it takes away time. i'd vote for deactivating that extra safety net until we have a solution that checks cpu time only. |
@snusnu Lets disable it for now. I dislike options. |
@@ -43,7 +43,7 @@ class Length < Rule | |||
# | |||
# @api private | |||
def valid? | |||
summary_text.split(//).length <= MAXIMUM_LINE_LENGTH | |||
summary_text.length <= MAXIMUM_LINE_LENGTH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this will return the same answer on ruby 1.8 as it would under 1.9 or 2.0. A cross-version approach would probably be:
summary_text.split(//u).length <= MAXIMUM_LINE_LENGTH
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need yardstick under 1.8? I don't think so. Specs of our apps should pass, but IMHO there is no reason to add complexity to our tools. Especially as tool result under 1.8 is not relevant.
IMHO we could just drop 1.8 support from all our "tools". Like we did in mutant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
split(//u)
works correctly with multibyte characters under 1.8, but I'm not sure how to make mutant pass.
Alive: rspec:Yardstick::Rules::Summary::Length#valid?:/Users/indrek/yardstick/lib/yardstick/rules/summary.rb:45:75b73 (0.11s)
@@ -1,4 +1,4 @@
def valid?
- ((summary_text.split(//u).length) <= (MAXIMUM_LINE_LENGTH))
+ ((summary_text.length) <= (MAXIMUM_LINE_LENGTH))
end
@mbj any ideas?
For 1.8 I'd make a test:
context 'with short summary that includes umlauts' do
let(:text) { 'ö' * 79 }
it { should be(true) }
end
but this passes without split(//u)
in 1.9, so the mutant thinks it is not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@indrekj I have one alternate approach. Since yardstick uses backports, under 1.8 we have String#chars
available. We could change that code to:
summary_text.chars.count <= MAXIMUM_LINE_LENGTH
Which should produce the same result in 1.8 and 1.9 and pass through mutant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mbj I agree with you in principle, but I'd rather only drop support when the effort to support 1.8 is significant (or impossible in the case of some tools). We're getting closer to that, but I don't think we're there yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@indrekj that is odd. I swear I tested it locally under 1.8.7 before suggesting it.
I wonder if this will work:
'ö'.split(//u).count
Also, do you mind submitting an issue to backports about #chars
behaviour being different? I don't know if @marcandre would consider it a bug but it's worth passing along just in case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is very unlikely we'll have multibyte chars in the description. So why not stick to String#length here? It might return incorrect values under 1.8, but the likeliness it triggers user fancing misbehavior is low.
Sorry for reposting, but I posted out of thread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, split(//u)
worked correctly, but I had trouble testing it with mutant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@indrekj the difference is we're calling #count
not #length
. That should allow it to pass with mutant because when mutant removes the split(//u)
statement an exception will be thrown, causing the mutation to be killed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dkubb Yes, you're right. I did not think about it like that :).
@dkubb @mbj please excuse my snarky comment but...this conversation seems to be a significant effort. I wholeheartedly agree with @mbj that adding complexity to a tool that could work only in 1.9 mode is a wasted effort. yardstick is such a tool, there's no good reason why it must work under 1.8. People could just use it under > 1.9 (just like we run all our metric stuff only under 1.9.3 these days). We talked about 1.8 support plenty of times but months are passing and we're still wasting time trying to support it with very little to none benefit. I know there are many apps out there running under 1.8 but at the same time there are many apps running under 1.9 and more apps that will run under 1.9 or 2.0 are being under development. I think we should focus our efforts on the future instead of trying to be nice to people being stuck on 1.8. Why? Because I'm not so sure if those people will ever benefit from using our libs, they have probably bigger problems to solve, like...porting their apps to ruby 2.0. I'm just saying supporting 1.8 is a significant effort (time wise) and it's simply not worth the price because benefits coming from 1.8 support are too small these days. ...but yeah, your repo your rules. Just me 2 cents :) |
Is there anything else I should change here? |
@indrekj thanks for pinging me on this. It's awesome. I will merge this now. |
@indrekj I'm already using your changes in private projects. Thx! |
@indrekj I think I'm going to do a yardstick release with your new changes very shortly. I'll probably bump the minor number this time. Thanks again! |
@dkubb Thx. I was about to ask ;) |
At the moment the |
@indrekj that sounds good. I'll do a point release after that unless you beat me to it. |
No description provided.