Skip to content

Commit 8742a1e

Browse files
committed
add validation of certificate identifier in codechecl.yml validation
1 parent a88cc63 commit 8742a1e

File tree

13 files changed

+193
-10
lines changed

13 files changed

+193
-10
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: codecheck
22
Title: Helper Functions for CODECHECK Project
3-
Version: 0.17.0
3+
Version: 0.18.0
44
Authors@R:
55
c(person(given = "Stephen",
66
family = "Eglen",

R/configuration.R

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,13 @@ validate_codecheck_yml <- function(configuration) {
204204
stop("Could not load codecheck configuration from input '", configuration, "'")
205205
}
206206

207+
# MUST have a non-empty certificate identifier matching the pattern NNNN-NNN
208+
assertthat::assert_that(isTRUE(grepl("^\\d{4}-\\d{3}$", codecheck_yml$certificate)), # if certificate is missing, grepl returns a logical(0)
209+
msg = paste0("The certificate identifier '",
210+
codecheck_yml$certificate,
211+
"' is missing or invalid")
212+
)
213+
207214
# MUST have manifest
208215
assertthat::assert_that(assertthat::has_name(codecheck_yml, "manifest"),
209216
msg = paste0("codecheck.yml must have a root-level node 'manifest'",
@@ -235,9 +242,8 @@ validate_codecheck_yml <- function(configuration) {
235242

236243
# Check if the paper_link contains a valid URL. We only check that it starts with https?://
237244
url_regex <- "^https?://"
238-
if (!grepl(url_regex, codecheck_yml$paper$reference)) {
239-
warning("The paper reference in the codecheck.yml is not a valid URL")
240-
}
245+
assertthat::assert_that(grepl(url_regex, codecheck_yml$paper$reference),
246+
msg = paste0(codecheck_yml$paper$reference, " is not a valid URL"))
241247

242248
# if ORCID are used, they must be without URL prefix and valid form, actual checking requires login, see #11
243249
orcid_regex <- "^(\\d{4}\\-\\d{4}\\-\\d{4}\\-\\d{3}(\\d|X))$"

inst/tinytest/test_codecheck_yml.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ tinytest::using(ttdo)
44
expect_silent(validate_codecheck_yml("yaml/codecheck.yml"))
55
expect_true(validate_codecheck_yml("yaml/codecheck.yml"))
66

7+
# certificate ID ----
8+
expect_error(validate_codecheck_yml("yaml/certificate_id_missing/codecheck.yml"),
9+
pattern = "'' is missing or invalid")
10+
expect_error(validate_codecheck_yml("yaml/certificate_id_invalid/codecheck1.yml"),
11+
pattern = "'20XX-000' is missing or invalid")
12+
expect_error(validate_codecheck_yml("yaml/certificate_id_invalid/codecheck2.yml"),
13+
pattern = "'2025-99' is missing or invalid")
14+
expect_error(validate_codecheck_yml("yaml/certificate_id_invalid/codecheck3.yml"),
15+
pattern = "'' is missing or invalid")
716
# manifest ----
817
expect_error(validate_codecheck_yml("yaml/manifest_missing/codecheck.yml"),
918
pattern = "root-level node 'manifest'")

inst/tinytest/yaml/author_name_missing/codecheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ summary: >
2626
paper; natural images provided by Peter Hancock.
2727
repository: https://github.com/codecheckers/Reproduction-Hancock
2828
check_time: "2020-04-13 10:00:00"
29-
certificate: 2020-XYZ
29+
certificate: 2020-999
3030
report: https://doi.org/10.5281/zenodo.FIXME
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
version: https://codecheck.org.uk/spec/config/1.0
3+
4+
paper:
5+
title: >
6+
The principal components of natural images
7+
authors:
8+
- name: Peter J. B. Hancock
9+
- name: Roland J. Baddeley
10+
- name: Leslie S. Smith
11+
ORCID: 0000-0002-3716-8013
12+
reference: http://pdfs.semanticscholar.org/7dcf/a42cfe3b59becb441844b72558b361693608.pdf
13+
14+
manifest:
15+
- file: Figure2.png
16+
comment: manuscript Figure 2
17+
- file: Figure3.png
18+
comment: manuscript Figure 3
19+
- file: Figure4.png
20+
comment: manuscript Figure 4
21+
- file: Figure5.png
22+
comment: manuscript Figure 5
23+
- file: Figure6.png
24+
comment: manuscript Figure 6
25+
- file: Figure7.png
26+
comment: manuscript Figure 7
27+
- file: Figure8.png
28+
comment: manuscript Figure 8
29+
30+
codechecker:
31+
- name: Stephen J. Eglen
32+
ORCID: 0000-0001-8607-8025
33+
- name: Daniel Nüst
34+
ORCID: 0000-0002-0024-5046
35+
36+
summary: >
37+
Matlab code written by Iain Davies to reproduce original
38+
paper; natural images provided by Peter Hancock.
39+
repository: https://github.com/codecheckers/Reproduction-Hancock
40+
check_time: "2020-04-13 10:00:00"
41+
certificate: 20XX-000
42+
report: https://doi.org/10.5281/zenodo.FIXME
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
version: https://codecheck.org.uk/spec/config/1.0
3+
4+
paper:
5+
title: >
6+
The principal components of natural images
7+
authors:
8+
- name: Peter J. B. Hancock
9+
- name: Roland J. Baddeley
10+
- name: Leslie S. Smith
11+
ORCID: 0000-0002-3716-8013
12+
reference: http://pdfs.semanticscholar.org/7dcf/a42cfe3b59becb441844b72558b361693608.pdf
13+
14+
manifest:
15+
- file: Figure2.png
16+
comment: manuscript Figure 2
17+
- file: Figure3.png
18+
comment: manuscript Figure 3
19+
- file: Figure4.png
20+
comment: manuscript Figure 4
21+
- file: Figure5.png
22+
comment: manuscript Figure 5
23+
- file: Figure6.png
24+
comment: manuscript Figure 6
25+
- file: Figure7.png
26+
comment: manuscript Figure 7
27+
- file: Figure8.png
28+
comment: manuscript Figure 8
29+
30+
codechecker:
31+
- name: Stephen J. Eglen
32+
ORCID: 0000-0001-8607-8025
33+
- name: Daniel Nüst
34+
ORCID: 0000-0002-0024-5046
35+
36+
summary: >
37+
Matlab code written by Iain Davies to reproduce original
38+
paper; natural images provided by Peter Hancock.
39+
repository: https://github.com/codecheckers/Reproduction-Hancock
40+
check_time: "2020-04-13 10:00:00"
41+
certificate: 2025-99
42+
report: https://doi.org/10.5281/zenodo.FIXME
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
version: https://codecheck.org.uk/spec/config/1.0
3+
4+
paper:
5+
title: >
6+
The principal components of natural images
7+
authors:
8+
- name: Peter J. B. Hancock
9+
- name: Roland J. Baddeley
10+
- name: Leslie S. Smith
11+
ORCID: 0000-0002-3716-8013
12+
reference: http://pdfs.semanticscholar.org/7dcf/a42cfe3b59becb441844b72558b361693608.pdf
13+
14+
manifest:
15+
- file: Figure2.png
16+
comment: manuscript Figure 2
17+
- file: Figure3.png
18+
comment: manuscript Figure 3
19+
- file: Figure4.png
20+
comment: manuscript Figure 4
21+
- file: Figure5.png
22+
comment: manuscript Figure 5
23+
- file: Figure6.png
24+
comment: manuscript Figure 6
25+
- file: Figure7.png
26+
comment: manuscript Figure 7
27+
- file: Figure8.png
28+
comment: manuscript Figure 8
29+
30+
codechecker:
31+
- name: Stephen J. Eglen
32+
ORCID: 0000-0001-8607-8025
33+
- name: Daniel Nüst
34+
ORCID: 0000-0002-0024-5046
35+
36+
summary: >
37+
Matlab code written by Iain Davies to reproduce original
38+
paper; natural images provided by Peter Hancock.
39+
repository: https://github.com/codecheckers/Reproduction-Hancock
40+
check_time: "2020-04-13 10:00:00"
41+
certificate: ""
42+
report: https://doi.org/10.5281/zenodo.FIXME
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
version: https://codecheck.org.uk/spec/config/1.0
3+
4+
paper:
5+
title: >
6+
The principal components of natural images
7+
authors:
8+
- name: Peter J. B. Hancock
9+
- name: Roland J. Baddeley
10+
- name: Leslie S. Smith
11+
ORCID: 0000-0002-3716-8013
12+
reference: http://pdfs.semanticscholar.org/7dcf/a42cfe3b59becb441844b72558b361693608.pdf
13+
14+
manifest:
15+
- file: Figure2.png
16+
comment: manuscript Figure 2
17+
- file: Figure3.png
18+
comment: manuscript Figure 3
19+
- file: Figure4.png
20+
comment: manuscript Figure 4
21+
- file: Figure5.png
22+
comment: manuscript Figure 5
23+
- file: Figure6.png
24+
comment: manuscript Figure 6
25+
- file: Figure7.png
26+
comment: manuscript Figure 7
27+
- file: Figure8.png
28+
comment: manuscript Figure 8
29+
30+
codechecker:
31+
- name: Stephen J. Eglen
32+
ORCID: 0000-0001-8607-8025
33+
- name: Daniel Nüst
34+
ORCID: 0000-0002-0024-5046
35+
36+
summary: >
37+
Matlab code written by Iain Davies to reproduce original
38+
paper; natural images provided by Peter Hancock.
39+
repository: https://github.com/codecheckers/Reproduction-Hancock
40+
check_time: "2020-04-13 10:00:00"
41+
certificate:
42+
report: https://doi.org/10.5281/zenodo.FIXME

inst/tinytest/yaml/codecheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ summary: >
3838
paper; natural images provided by Peter Hancock.
3939
repository: https://github.com/codecheckers/Reproduction-Hancock
4040
check_time: "2020-04-13 10:00:00"
41-
certificate: 2020-XYZ
41+
certificate: 2020-000
4242
report: https://doi.org/10.5281/zenodo.FIXME

inst/tinytest/yaml/codechecker_name_missing/codecheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ summary: >
3737
paper; natural images provided by Peter Hancock.
3838
repository: https://github.com/codecheckers/Reproduction-Hancock
3939
check_time: "2020-04-13 10:00:00"
40-
certificate: 2020-XYZ
40+
certificate: 2020-999
4141
report: https://doi.org/10.5281/zenodo.FIXME

0 commit comments

Comments
 (0)