Closed anselmbradford closed 10 years ago
This is the type of file (line 6 it appears) that the error is being thrown at
<%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
<%%= f.error_notification %>
<div class="form-inputs">
<%- attributes.each do |attribute| -%>
<%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %>
<%- end -%>
</div>
<div class="form-actions">
<%%= f.button :submit %>
</div>
<%% end %>
See an example here: https://github.com/dockyard/igata/blob/master/lib/templates/erb/scaffold/_form.html.erb
Hmm, will look at a quick fix for that later today.
So, the issue is the braindead way metric_fu is parsing the flay output.
Given
******* STARTING METRIC flay
Total score (lower is better) = 494
1) IDENTICAL code found in :defn (mass*2 = 196)
app/models/template_demo.rb:61
app/models/template_purchase.rb:58
2) IDENTICAL code found in :defn (mass*2 = 144)
app/models/template_demo.rb:16
app/models/template_purchase.rb:25
3) Similar code found in :resbody (mass = 58)
app/models/template.rb:80
app/models/template.rb:125
4) Similar code found in :defn (mass = 50)
app/controllers/my_templates_git_controller.rb:4
app/controllers/my_templates_git_controller.rb:10
5) Similar code found in :call (mass = 46)
app/inputs/checkbox_list_input.rb:25
app/inputs/screenshots_input.rb:22
ERRORS:
lib/templates/erb/scaffold/_form.html.erb:6 :: parse error on value ";" (tSEMI)
skipping lib/templates/erb/scaffold/_form.html.erb
metric_fu 'parses' it with @output.chomp.split("\n\n").map{|m| m.split("\n ") }
and then each element with
reason = problem.shift.strip
lines_info = problem.map do |full_line|
name, line = full_line.split(":")
{:name => name.strip, :line => line.strip}
which results in reason 5) Similar code found in :call (mass = 46)
being 'parsed' as
[
"app/inputs/checkbox_list_input.rb:25",
"app/inputs/screenshots_input.rb:22\nERRORS:",
"lib/templates/erb/scaffold/_form.html.erb:6 :: parse error on value \";\" (tSEMI)",
"skipping lib/templates/erb/scaffold/_form.html.erb"
]
Due to the lack of \n between the last 'reason' and the 'ERRORS', the split on '\n\n' lumps them together. The 'problem' should be
[
"app/inputs/checkbox_list_input.rb:25",
"app/inputs/screenshots_input.rb:22",
]
A quick fix would be to change full_line.split(":")
to full_line.split(":").map(&:strip)
, though that would erroneously include the error text in the report
And the ERRORS line comes from capturing stderr in the gem_run... so... that's on me, it appears
Thanks for the quick fix!
With metric_fu 4.11.0 installed (latest release), I get the following error when running
metric_fu
:Here's my debug output:
My Gemfile.lock looks like: