Skip to content

add default to all switch statements in src; coverage#3720

Merged
mattdowle merged 3 commits intomasterfrom
switch_default
Jul 23, 2019
Merged

add default to all switch statements in src; coverage#3720
mattdowle merged 3 commits intomasterfrom
switch_default

Conversation

@MichaelChirico
Copy link
Copy Markdown
Member

Inspired by: #3692 (comment)

Ran:

for (f in list.files('src', pattern = '\\.c', full.names = TRUE)) {
  l = readLines(f)
  nswitch = sum(grepl('switch\\s*\\(', l))
  ndefault = sum(grepl('default\\s*:', l))
  if (nswitch != ndefault)
    cat(sprintf('%s switches: %d, defaults: %d\n', basename(f), nswitch, ndefault))
}

And found the files here with default-less switches. Added internal errors for them+nocov'd, except in the one case where it was actually reasonable to reach there. Had to make a small edit to writeNA to make it even easier to do so (even without that fill=expression(1) would get there).

Mostly, the default-less switches are switch(enum) so it should be impossible in the current code to reach. These errors guard against editing the enums' valid values in the future & neglecting to cover all the bases in testing new functionality.

@codecov
Copy link
Copy Markdown

codecov bot commented Jul 21, 2019

Codecov Report

Merging #3720 into master will increase coverage by 0.34%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #3720      +/-   ##
=========================================
+ Coverage   98.45%   98.8%   +0.34%     
=========================================
  Files          69      69              
  Lines       13287   13285       -2     
=========================================
+ Hits        13082   13126      +44     
+ Misses        205     159      -46
Impacted Files Coverage Δ
src/nafill.c 100% <ø> (ø) ⬆️
src/assign.c 100% <ø> (ø) ⬆️
src/fcast.c 100% <ø> (+15.51%) ⬆️
src/frollR.c 100% <ø> (ø) ⬆️
src/frank.c 100% <100%> (+8.26%) ⬆️
src/bmerge.c 98.25% <100%> (ø) ⬆️
src/ijoin.c 95.29% <100%> (+0.2%) ⬆️
src/gsumm.c 100% <0%> (+2.71%) ⬆️

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 5ca3366...d02ca73. Read the comment docs.

@MichaelChirico MichaelChirico changed the title add default to all switch statements in src add default to all switch statements in src; coverage Jul 22, 2019
add coverage tests of touched files

fix test

vestigial msg
@mattdowle mattdowle added this to the 1.12.4 milestone Jul 22, 2019
Comment thread src/fcast.c Outdated
Copy link
Copy Markdown
Member

@mattdowle mattdowle left a comment

Choose a reason for hiding this comment

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

LGTM. Just minor changes please.

Comment thread src/frollR.c Outdated
Comment thread src/ijoin.c Outdated
@MichaelChirico
Copy link
Copy Markdown
Member Author

@mattdowle done with {, there are still a bunch of whitespace changes, shall I bother?

-w diff in UI:

https://github.com/Rdatatable/data.table/pull/3720/files?w=1

@mattdowle
Copy link
Copy Markdown
Member

great. no worries - I did the whitespace as I was in diff anyway

@mattdowle
Copy link
Copy Markdown
Member

Wow - that's an increase of 0.34% coverage! That's a pretty big bang for that buck of relatively few lines.

@mattdowle mattdowle merged commit 3cb517b into master Jul 23, 2019
@mattdowle mattdowle deleted the switch_default branch July 23, 2019 00:41
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.

2 participants