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

Fix #260 #262

Merged
merged 5 commits into from
Nov 2, 2017
Merged

Fix #260 #262

merged 5 commits into from
Nov 2, 2017

Conversation

wlandau
Copy link
Contributor

@wlandau wlandau commented Sep 1, 2017

  • Add the summary.lints() function. Taken from @jimhester in Attenuate the verbosity in lint_package() #260 and modified. I have a mild preference to
    1. sort by file name and
    2. make sure a predictable 4-column data frame is returned whether lints are found or not.
  • Test summary.lints() on tidy and untidy code.
  • Fix tests/testthat/checkstyle.xml (version given must agree with lintr version).
  • Remove trailing whitespace from test-methods.R.

@codecov-io
Copy link

codecov-io commented Sep 1, 2017

Codecov Report

Merging #262 into master will decrease coverage by 0.23%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #262      +/-   ##
==========================================
- Coverage   86.12%   85.88%   -0.24%     
==========================================
  Files          39       40       +1     
  Lines        2183     2225      +42     
==========================================
+ Hits         1880     1911      +31     
- Misses        303      314      +11
Impacted Files Coverage Δ
R/methods.R 42.45% <100%> (+5.33%) ⬆️
R/settings.R 93.87% <0%> (-1.58%) ⬇️
R/addins.R 0% <0%> (ø)
R/exclude.R 95.12% <0%> (+0.18%) ⬆️
R/cache.R 96.59% <0%> (+1.52%) ⬆️
R/lint.R 75.12% <0%> (+3.55%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5431140...4618ac3. Read the comment docs.

@wlandau
Copy link
Contributor Author

wlandau commented Sep 1, 2017

Sorry about the missing coverage report. I manually made sure all of summary.lints() was covered, so it should have only increased. Is there any action I can take on my end to fix this?

@jimhester
Copy link
Member

You can ignore the coverage report issues.

types <- factor(vapply(object, `[[`, character(1), "type"),
levels = c("style", "warning", "error"))
tbl <- table(filenames, types)
filenames <- rownames(tbl)
Copy link
Member

Choose a reason for hiding this comment

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

change this line to

filenames <- rownames(tbl) %||% character()

Then you can remove the entire conditional at https://github.com/jimhester/lintr/pull/262/files#diff-a0a9d3c78e9f113319e5e069fb2697ecR155

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now fixed.

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="lintr-1.0.0.9001">
<checkstyle version="lintr-1.0.1">
Copy link
Member

Choose a reason for hiding this comment

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

Try to keep unrelated changes out of PRs. If you do include them they should be in separate commits.

Copy link
Contributor Author

@wlandau wlandau Sep 1, 2017

Choose a reason for hiding this comment

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

Sorry about that. And given that you just bumped the version, I think I also created a merge conflict. Resolving in a separate commit.

on.exit(unlink(file))

writeLines(good, con = file, sep = "\n")
expect_silent(out <- summary(lint(file)))
Copy link
Member

Choose a reason for hiding this comment

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

I think this test would be more clear if you did something like

no_lints <- lint(
"if (1 > 0){
   print(\"good\")
}")
no_lint_summary <- summary(no_lints)
# ... tests

has_lints <- lint(
"if(1>0){
  print  ('bad')
}")

has_lint_summary <- summary(has_lints)
# ... tests

Also I would explicitly pass linters to lint() rather than relying on the default ones. The defaults can change over time so they could potentially break this test if new linters are added.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. Just cleaned this up.

- Make the intent of the `summary.lints()` tests clearer. 
- Divide into 2 tests (no lints vs lints found).
- Use assignment linter explicitly.
@jimhester
Copy link
Member

Ok, all this needs is a note in the NEWS.md file explaining the new feature and thanking yourself and this PR.

@wlandau
Copy link
Contributor Author

wlandau commented Nov 2, 2017

Done, thanks!

@jimhester jimhester merged commit 79eaa32 into r-lib:master Nov 2, 2017
@jimhester
Copy link
Member

Thanks!

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.

None yet

4 participants