Skip to content

Commit 64997c6

Browse files
committed
remove tools and simplify coverage reporting
1 parent 73e1910 commit 64997c6

6 files changed

Lines changed: 96 additions & 50 deletions

File tree

.Rbuildignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,3 @@
2424
^\.RData$
2525
^\.Ruserdata$
2626
^Makefile$
27-
^tools$

Makefile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
.PHONY: help check test coverage doc build install clean
2+
3+
help:
4+
@echo "Available commands:"
5+
@echo " make check - Run R CMD check"
6+
@echo " make test - Run tests"
7+
@echo " make coverage - Check code coverage"
8+
@echo " make doc - Generate documentation"
9+
@echo " make build - Build package"
10+
@echo " make install - Install package locally"
11+
@echo " make clean - Clean build artifacts"
12+
13+
check:
14+
R CMD check .
15+
16+
test:
17+
Rscript -e "devtools::test()"
18+
19+
coverage:
20+
@echo "Running code coverage analysis..."
21+
Rscript -e "cov <- covr::package_coverage(quiet = FALSE); print(cov); cat('Coverage: ', covr::percent_coverage(cov), '%\n')"
22+
23+
doc:
24+
Rscript -e "devtools::document()"
25+
26+
build:
27+
R CMD build .
28+
29+
install:
30+
Rscript -e "devtools::install()"
31+
32+
clean:
33+
rm -f *.tar.gz
34+
rm -rf guess.Rcheck
35+
rm -f .Rhistory

NEWS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
* **Documentation improvements**: Enhanced validation function documentation with proper `@importFrom` declarations
1313

1414
## Development Workflow Improvements
15-
* **Local code coverage**: Replaced Codecov.io with local coverage reporting
16-
- Added `tools/check_coverage.R` for local coverage analysis
15+
* **Local code coverage**: Replaced Codecov.io with simple local coverage reporting
16+
- Added `make coverage` command for quick coverage analysis
1717
- Created `Makefile` for common development tasks
1818
- Removed external Codecov dependency and badge
1919
* **Fixed CRAN URL**: Updated to canonical CRAN package URL format

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ make doc
5555
Or run coverage directly in R:
5656
```r
5757
# Check code coverage
58-
source("tools/check_coverage.R")
58+
cov <- covr::package_coverage()
59+
print(cov)
5960
```
6061

6162
### Key Functions

tests/testthat/test-lca-adj.R

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
context("Test LCA Adjustment Function")
2+
3+
test_that("lca_adj works with basic data", {
4+
# Create test data with DK responses
5+
pre_test <- data.frame(
6+
item1 = c(1, 0, 0, 1, "d", 1, 0, "d"),
7+
item2 = c(1, 0, 1, "d", 0, "d", 1, 0)
8+
)
9+
pst_test <- data.frame(
10+
item1 = c(1, 1, 0, "d", 1, 0, "d", 1),
11+
item2 = c(1, 0, 1, 0, "d", 1, "d", 0)
12+
)
13+
14+
# Test basic functionality
15+
result <- lca_adj(pre_test, pst_test)
16+
17+
# Check structure
18+
expect_type(result, "list")
19+
expect_named(result, c("pre", "pst"))
20+
21+
# Check that something was returned (basic smoke test)
22+
expect_true(!is.null(result$pre))
23+
expect_true(!is.null(result$pst))
24+
})
25+
26+
test_that("lca_adj handles NA values", {
27+
# Create test data with NAs and DK
28+
pre_test <- data.frame(
29+
item1 = c(1, 0, NA, 1, "d", 0, 1, "d"),
30+
item2 = c(1, NA, 1, "d", 0, "d", 1, 0)
31+
)
32+
pst_test <- data.frame(
33+
item1 = c(1, 1, 0, "d", NA, 1, "d", 0),
34+
item2 = c(NA, 0, 1, 0, "d", 0, "d", 1)
35+
)
36+
37+
# Should produce a warning about NA conversion
38+
expect_warning(
39+
result <- lca_adj(pre_test, pst_test),
40+
"NAs will be converted to 0"
41+
)
42+
43+
# Check that function still works
44+
expect_type(result, "list")
45+
expect_named(result, c("pre", "pst"))
46+
})
47+
48+
test_that("lca_adj validates basic inputs", {
49+
# Test with NULL inputs (should error)
50+
expect_error(lca_adj(NULL, NULL))
51+
52+
# Test basic functionality doesn't crash
53+
pre_test <- data.frame(item1 = c(1, 0, "d", 1, 0))
54+
pst_test <- data.frame(item1 = c(1, "d", 1, 0, 1))
55+
56+
expect_no_error(result <- lca_adj(pre_test, pst_test))
57+
})

tools/check_coverage.R

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)