Skip to content
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

Remove warning about unused local variable. #24

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions lib/simplecov-html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,21 @@ def formatted_source_file(source_file)
# Returns a table containing the given source files
def formatted_file_list(title, source_files)
title_id = title.gsub(/^[^a-zA-Z]+/, '').gsub(/[^a-zA-Z0-9\-\_]/, '')
title_id # Ruby will give a warning when we do not use this except via the binding :( FIXME
template('file_list').result(binding)
data = FileListData.new(title, title_id, source_files)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like overkill, no?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the downside of simplecov being a rather low-level tool - I've had plenty of reports about ruby warnings all around and yes, while it is incredibly silly to have this workaround in place, people seem to want warning-free libraries. Also, this particular piece broke the gem when I got a PR that removed the assignment and then in the vie the variable didn't exist :/

On 3. August 2014 14:39:49 MESZ, Benjamin Fleischer notifications@github.com wrote:

@@ -55,8 +55,21 @@ def formatted_source_file(source_file)

Returns a table containing the given source files

def formatted_file_list(title, source_files)
title_id = title.gsub(/^[^a-zA-Z]+/,
'').gsub(/[^a-zA-Z0-9-_]/, '')

  • title_id # Ruby will give a warning when we do not use this
    except via the binding :( FIXME
  • template('file_list').result(binding)
  • data = FileListData.new(title, title_id, source_files)

This seems like overkill, no?


Reply to this email directly or view it on GitHub:
https://github.com/colszowka/simplecov-html/pull/24/files#r15734293

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, having played with it a bit, I suppose this is the smallest change that fixes it. I started building a Template class and...

template('file_list').result(data.instance_eval { binding })
end

FileListData = Class.new(BasicObject) do
attr_reader :title, :title_id, :source_files
def initialize(title, title_id, source_files)
@title = title
@title_id = title_id
@source_files = source_files
end

def binding
::Kernel.binding
end
end

def coverage_css_class(covered_percent)
Expand Down