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

Add stats executable for reporting repo state. #1541

Closed
wants to merge 2 commits into from
Closed

Conversation

Awjin
Copy link
Contributor

@Awjin Awjin commented Jun 4, 2020

Closes #1517

@Awjin Awjin marked this pull request as draft June 4, 2020 19:21
@Awjin Awjin requested a review from nex3 June 4, 2020 19:22
Copy link
Contributor

@nex3 nex3 left a comment

Choose a reason for hiding this comment

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

Before this gets committed, it should also have some tests.

lib/sass_spec/stats/todo.rb Outdated Show resolved Hide resolved
lib/sass_spec/stats/todo.rb Outdated Show resolved Hide resolved
lib/sass_spec/stats/todo.rb Outdated Show resolved Hide resolved
lib/sass_spec/stats/todo.rb Outdated Show resolved Hide resolved
lib/sass_spec/stats/todo.rb Outdated Show resolved Hide resolved
lib/sass_spec/stats/todo.rb Outdated Show resolved Hide resolved
lib/sass_spec/stats/todo.rb Outdated Show resolved Hide resolved
end
entry[:impl] = impl
entry[:issue] = match =~ /#/ ? match.split("#")[-1] : "?"
todos[path].push(entry)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not necessarily something that needs to be fixed in this PR, but something that will probably need to be fixed at some point, is changing this to count the number of specs that are marked as TODO rather than counting the number of options files. A single options file at the root of a directory applies to every spec beneath that directory, so eventually you'll probably need to search for all tests (identified by input.{scss,css,sass} files) within the directory that contains the options.yml.

lib/sass_spec/stats/todo.rb Outdated Show resolved Hide resolved
lib/sass_spec/stats/todo.rb Outdated Show resolved Hide resolved
Copy link
Contributor

@nex3 nex3 left a comment

Choose a reason for hiding this comment

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

Looks like you may not have uploaded the new changes?

end
end

parser.on("--missing-issue", "Find todos that are missing a Github issue.") do
Copy link
Contributor

Choose a reason for hiding this comment

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

You can handle it manually by checking if options[:missing_issue] and options[:issue] are both set.

@Awjin
Copy link
Contributor Author

Awjin commented Jun 6, 2020

I addressed most comments; printing a nicely formatted report and specs are in flight.

Comment on lines +27 to +35
unless issue =~ /.+#\d+/
warn("Invalid issue.\n\n")
puts parser.help()
end
issue = issue.split("#")
number = issue.pop
issue = issue.join().split("/")
impl = issue.pop
options[:issue] = "#{impl}##{number}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
unless issue =~ /.+#\d+/
warn("Invalid issue.\n\n")
puts parser.help()
end
issue = issue.split("#")
number = issue.pop
issue = issue.join().split("/")
impl = issue.pop
options[:issue] = "#{impl}##{number}"
unless issue =~ /([^/]+#\d+)$/
warn("Invalid issue.\n\n")
puts parser.help()
end
options[:issue] = $1

@options = options
end

##
Copy link
Contributor

Choose a reason for hiding this comment

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

It's probably best to follow the doc comment style in the rest of the repo, which doesn't have this leading ##. I think you can omit the @param and @returns as well.

if @options[:missing_issue]
metadata = filter_todos_missing_issue(metadata)
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this supposed to return metadata as well?

Comment on lines +63 to +65
if @options[:todo]
metadata = filter_todos_by_implementation(metadata)
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Style nit:

Suggested change
if @options[:todo]
metadata = filter_todos_by_implementation(metadata)
end
metadata = filter_todos_by_implementation(metadata) if @options[:todo]

This will let you write what currently takes 11 lines in 3 without losing much readability 😃.

Comment on lines +121 to +124
def get_yaml(metadata)
dir = SassSpec::Directory.new(metadata.name)
YAML.load(dir.read("options.yml"))
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than re-reading the metadata here, maybe it would be better to have the Metadata object store the raw options map.

metadata.select do |meta|
todos = meta.options[:todo]
next unless todos
todos.select { |todo| todo.include? @options[:todo] }.any?
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use Metadata#todo? here?

#
# @return [Array<SassSpec::TestCaseMetadata>]
def get_metadata
dirs = @options[:dirs] || [SassSpec::SPEC_DIR].map do |dir|
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
dirs = @options[:dirs] || [SassSpec::SPEC_DIR].map do |dir|
dirs = (@options[:dirs] || [SassSpec::SPEC_DIR]).map do |dir|

end

option_files = dirs.flat_map do |dir|
dir.glob("**/options.yml").map do |file|
Copy link
Contributor

Choose a reason for hiding this comment

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

At this point, I think it would be pretty easy to make this find all test cases by making this:

Suggested change
dir.glob("**/options.yml").map do |file|
dir.glob("**/input.{scss,sass,css}").map do |file|

@nex3 nex3 closed this Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add executable that prints information about the specs
2 participants