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

New --complete-descriptions flag to warn for data not described by metadata in label #686

Merged
merged 5 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/gov/nasa/pds/tools/validate/ProblemType.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ public enum ProblemType {

BAD_SCHEMATYPENS("warning.label.bad_schematypens"),

DATA_NOT_DESCRIBED("warning.data.not_described"),

MISSING_SCHEMATYPENS("warning.label.missing_schematypens"),

SCHEMATRON_WARNING("warning.label.schematron"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package gov.nasa.pds.tools.validate.rule.pds4;

import java.io.File;
import java.io.FileNotFoundException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
Expand All @@ -10,6 +11,7 @@
import java.util.Objects;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import gov.nasa.arc.pds.tools.util.FileUtils;
import gov.nasa.pds.label.Label;
import gov.nasa.pds.label.NameNotKnownException;
import gov.nasa.pds.label.ProductType;
Expand Down Expand Up @@ -79,6 +81,15 @@ public void validate() throws MalformedURLException, URISyntaxException {
// e.g. File_Area_Observational + File_Area_Observational_Supplemental

if (!obj.getDataFile().equals(previousDataFile)) {
if (previousDataFile != null) {
long filesize = new File(previousDataFile.getPath()).length();
if (minimumExpectedOffset < filesize) {
getListener().addProblem(new ValidationProblem(
new ProblemDefinition(ExceptionType.WARNING, ProblemType.DATA_NOT_DESCRIBED,
"Data not described at the end of the file: " + (filesize - minimumExpectedOffset) + " bytes"),
getTarget(), objectCounter, -1));
}
}
tableCounter = 0;
arrayCounter = 0;
headerCounter = 0;
Expand Down Expand Up @@ -109,9 +120,16 @@ public void validate() throws MalformedURLException, URISyntaxException {
// anything right now)
headerCounter++;
}

}

if (previousDataFile != null) {
long filesize = new File(previousDataFile.getPath()).length();
if (minimumExpectedOffset < filesize) {
getListener().addProblem(new ValidationProblem(
new ProblemDefinition(ExceptionType.WARNING, ProblemType.DATA_NOT_DESCRIBED,
"Data not described at the end of the file: " + (filesize - minimumExpectedOffset) + " bytes"),
getTarget(), objectCounter, -1));
}
}
LOG.debug("arrays validated: {}", arrayCounter);
LOG.debug("tables validated: {}", tableCounter);
LOG.debug("headers validated: {}", headerCounter);
Expand Down
4 changes: 4 additions & 0 deletions src/test/resources/features/validate.feature
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ Scenario Outline: Execute validate command for tests below.
# Validate#561
|"NASA-PDS/validate#597 Success Filenanme Does Not Contain Bundle/Collection" | "github561" | 0 | "0 errors expected" | "totalWarnings" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github561_1.json -s json -R pds4.collection --label-extension lblx --skip-context-validation -t {resourceDir}/github561" | "report_github561_1.json" |

# Validate#535
|"NASA-PDS/validate#535 Warning when excess table content" | "github535" | 1 | "1 warnings expected" | "DATA_NOT_DESCRIBED" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github535_1.json -s json -t {resourceDir}/github535/uvis_euv_2008_003_solar_time_series_ingress.xml" | "report_github535_1.json" |
|"NASA-PDS/validate#535 Warning when excess table content" | "github535" | 1 | "1 errors expected" | "TABLE_DEFINITION_PROBLEM" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github535_2.json -s json -t {resourceDir}/github535/uvis_euv_2016_288_solar_time_series_egress.xml" | "report_github535_2.json" |

# Validate#531
|"NASA-PDS/validate#531 Success Binary Field Group Lengths" | "github531" | 0 | "0 errors expected" | "totalErrors" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github531_1.json -s json -t {resourceDir}/github531/success/b.xml" | "report_github531_1.json" |
|"NASA-PDS/validate#531 Fail Binary Field Group Lengths" | "github531" | 1 | "1 errors expected" | "TABLE_DEFINITION_PROBLEM" | "src/test/resources" | "target/test" | "-r {reportDir}/report_github531_2.json -s json -t {resourceDir}/github531/fail/b.xml" | "report_github531_2.json" |
Expand Down
Loading