Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,22 @@
* @param constants
* @return
*/
private static boolean equalsStripped(String value, String constant) {
return constant != null && value.equals(constant.strip());
}
public static boolean isNonConformantSpecialConstant(String value, SpecialConstants constants) {
boolean matched = false;
if (constants != null) {
matched |= value.equals(constants.getErrorConstant());
matched |= value.equals(constants.getInvalidConstant());
matched |= value.equals(constants.getMissingConstant());
//matched |= value.equals(constants.getHighInstrumentSaturation());
//matched |= value.equals(constants.getHighRepresentationSaturation());
//matched |= value.equals(constants.getLowInstrumentSaturation());
//matched |= value.equals(constants.getLowRepresentationSaturation());
matched |= value.equals(constants.getNotApplicableConstant());
matched |= value.equals(constants.getSaturatedConstant());
matched |= value.equals(constants.getUnknownConstant());
matched |= equalsStripped(value, constants.getErrorConstant());
matched |= equalsStripped(value, constants.getInvalidConstant());
matched |= equalsStripped(value, constants.getMissingConstant());
//matched |= equalsStripped(value, constants.getHighInstrumentSaturation());

Check warning on line 40 in src/main/java/gov/nasa/pds/tools/validate/SpecialConstantChecker.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This block of commented-out lines of code should be removed.

See more on https://sonarcloud.io/project/issues?id=NASA-PDS_validate&issues=AaChZNwz6oLu0LuOTFb_&open=AaChZNwz6oLu0LuOTFb_&pullRequest=1680
//matched |= equalsStripped(value, constants.getHighRepresentationSaturation());
//matched |= equalsStripped(value, constants.getLowInstrumentSaturation());
//matched |= equalsStripped(value, constants.getLowRepresentationSaturation());
Comment on lines +40 to +43

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose your own adventure! You encounter some commented-out code. Do you:

  1. Add a comment above the code explaining why these 4 lines are commented out; or …
  2. Delete these 4 lines?

Both paths may lead to success … what do you decide? 🧙

matched |= equalsStripped(value, constants.getNotApplicableConstant());
matched |= equalsStripped(value, constants.getSaturatedConstant());
matched |= equalsStripped(value, constants.getUnknownConstant());
}
return matched;
}
Expand Down Expand Up @@ -164,6 +167,7 @@
}
public static boolean sameContent (Number number, String constant_repr, int radix) {
if (constant_repr == null) return false;
constant_repr = constant_repr.strip();
if (number.toString().equals(constant_repr)) {
return true;
}
Expand Down
3 changes: 3 additions & 0 deletions src/test/resources/features/4.2.x.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ Feature: 4.2.x
# github1660: missing_constant must suppress min/max range errors in ASCII table fields
| 1660 | 1 | "github1660" | "--skip-context-validation -t {datasrc}/pccds.xml" | "summary:productValidation:passed=1,summary:totalErrors=0,summary:totalWarnings=2,summary:messageTypes:warning.label.bad_schematypens=1,summary:messageTypes:warning.label.missing_schematron_spec=1" |

# github1656: missing_constant with leading/trailing whitespace must suppress min/max range errors
| 1656 | 1 | "github1656" | "--skip-context-validation -t {datasrc}/test_missing_constant_whitespace.xml" | "summary:productValidation:passed=1,summary:totalErrors=0,summary:totalWarnings=2,summary:messageTypes:warning.label.bad_schematypens=1,summary:messageTypes:warning.label.missing_schematron_spec=1" |

#end
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1.500,-1.000
2.300,-1.000
0.750,5.000
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="http://pds.nasa.gov/pds4/pds/v1/PDS4_PDS_1B00.sch" schemtatypens="http://purl.oclc.org/dsdl/schematron"?>

<Product_Observational xmlns="http://pds.nasa.gov/pds4/pds/v1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pds.nasa.gov/pds4/pds/v1 http://pds.nasa.gov/pds4/pds/v1/PDS4_PDS_1B00.xsd">

<Identification_Area>
<logical_identifier>urn:nasa:pds:test:data:missing_constant_whitespace</logical_identifier>
<version_id>1.0</version_id>
<title>Test: missing_constant with leading whitespace should suppress min/max warnings</title>
<information_model_version>1.11.0.0</information_model_version>
<product_class>Product_Observational</product_class>
</Identification_Area>

<Observation_Area>
<Time_Coordinates>
<start_date_time>2020-01-01Z</start_date_time>
<stop_date_time>2020-12-31Z</stop_date_time>
</Time_Coordinates>
<Primary_Result_Summary>
<purpose>Science</purpose>
<processing_level>Derived</processing_level>
</Primary_Result_Summary>
<Investigation_Area>
<name>None</name>
<type>Other Investigation</type>
<Internal_Reference>
<lid_reference>urn:nasa:pds:context:investigation:individual.none</lid_reference>
<reference_type>data_to_investigation</reference_type>
</Internal_Reference>
</Investigation_Area>
<Observing_System>
<Observing_System_Component>
<name>Test Instrument</name>
<type>Instrument</type>
</Observing_System_Component>
</Observing_System>
<Target_Identification>
<name>Test Target</name>
<type>Comet</type>
</Target_Identification>
</Observation_Area>

<File_Area_Observational>
<File>
<file_name>test_missing_constant_whitespace.csv</file_name>
<records>3</records>
</File>
<Table_Delimited>
<name>Test Table</name>
<local_identifier>TABLE</local_identifier>
<offset unit="byte">0</offset>
<parsing_standard_id>PDS DSV 1</parsing_standard_id>
<records>3</records>
<record_delimiter>Carriage-Return Line-Feed</record_delimiter>
<field_delimiter>Comma</field_delimiter>
<Record_Delimited>
<fields>2</fields>
<groups>0</groups>
<Field_Delimited>
<name>measurement</name>
<field_number>1</field_number>
<data_type>ASCII_Real</data_type>
<Field_Statistics>
<maximum>10000.0</maximum>
<minimum>0.001</minimum>
</Field_Statistics>
</Field_Delimited>
<Field_Delimited>
<name>quality_flag</name>
<field_number>2</field_number>
<data_type>ASCII_Real</data_type>
<Special_Constants>
<missing_constant> -1.000</missing_constant>
</Special_Constants>
<Field_Statistics>
<maximum>10000.000</maximum>
<minimum>0.001</minimum>
</Field_Statistics>
</Field_Delimited>
</Record_Delimited>
</Table_Delimited>
</File_Area_Observational>

</Product_Observational>
Loading