Skip to content

Commit

Permalink
Fix ErrorProne and deprecated warnings.
Browse files Browse the repository at this point in the history
Couldn't figure out the reference equality issues in CallbackValidatorTest, so I suppressed it.
  • Loading branch information
Capstan committed Oct 29, 2019
1 parent 49ecb1a commit 9a98166
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
public final class InvalidInstanceException
extends ProcessingException
{
private static final long serialVersionUID = -3273787152985150466L;

public InvalidInstanceException(final ProcessingMessage message)
{
super(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
import org.joda.time.format.DateTimeFormatterBuilder;
import org.joda.time.format.DateTimeParser;

import java.util.List;

import static org.joda.time.DateTimeFieldType.*;

/**
Expand All @@ -41,7 +39,7 @@
public final class DateTimeAttribute
extends AbstractFormatAttribute
{
private static final List<String> FORMATS = ImmutableList.of(
private static final ImmutableList<String> FORMATS = ImmutableList.of(
"yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-MM-dd'T'HH:mm:ss.[0-9]{1,12}Z"
);
private static final DateTimeFormatter FORMATTER;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.github.fge.jsonschema.format.common;

import java.util.List;

import com.github.fge.jsonschema.cfg.ValidationConfiguration;
import com.github.fge.jsonschema.library.DraftV4Library;
import org.joda.time.format.DateTimeFormatter;
Expand Down Expand Up @@ -31,7 +29,7 @@
*/
public class RFC3339DateTimeAttribute extends AbstractFormatAttribute {

private static final List<String> RFC3339_FORMATS = ImmutableList.of(
private static final ImmutableList<String> RFC3339_FORMATS = ImmutableList.of(
"yyyy-MM-dd'T'HH:mm:ss((+|-)HH:mm|Z)", "yyyy-MM-dd'T'HH:mm:ss.[0-9]{1,12}((+|-)HH:mm|Z)"
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.github.fge.jackson.NodeType;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import com.github.fge.jsonschema.core.report.ProcessingReport;
import com.github.fge.jsonschema.core.util.RhinoHelper;
import com.github.fge.jsonschema.core.util.RegexECMA262Helper;
import com.github.fge.jsonschema.format.AbstractFormatAttribute;
import com.github.fge.jsonschema.format.FormatAttribute;
import com.github.fge.jsonschema.processors.data.FullData;
Expand All @@ -34,7 +34,7 @@
* <p>Again, here, we do <b>not</b> use {@link java.util.regex} because it does
* not fit the bill.</p>
*
* @see RhinoHelper
* @see RegexECMA262Helper
*/
public final class RegexAttribute
extends AbstractFormatAttribute
Expand All @@ -58,7 +58,7 @@ public void validate(final ProcessingReport report,
{
final String value = data.getInstance().getNode().textValue();

if (!RhinoHelper.regexIsValid(value))
if (!RegexECMA262Helper.regexIsValid(value))
report.error(newMsg(data, bundle, "err.format.invalidRegex")
.putArgument("value", value));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ public JsonNode digest(final JsonNode schema)
case STRING:
propertyDeps.put(key, FACTORY.arrayNode()
.add(value.textValue()));
break;
default:
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import com.github.fge.jsonschema.core.processing.Processor;
import com.github.fge.jsonschema.core.report.ProcessingReport;
import com.github.fge.jsonschema.core.util.RhinoHelper;
import com.github.fge.jsonschema.core.util.RegexECMA262Helper;
import com.github.fge.jsonschema.keyword.validator.AbstractKeywordValidator;
import com.github.fge.jsonschema.processors.data.FullData;
import com.github.fge.msgsimple.bundle.MessageBundle;
Expand Down Expand Up @@ -84,7 +84,7 @@ public void validate(final Processor<FullData, FullData> processor,

for (final String field: fields)
for (final String regex: patternProperties)
if (RhinoHelper.regMatch(regex, field))
if (RegexECMA262Helper.regMatch(regex, field))
tmp.add(field);

fields.removeAll(tmp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import com.github.fge.jsonschema.core.processing.Processor;
import com.github.fge.jsonschema.core.report.ProcessingReport;
import com.github.fge.jsonschema.core.util.RhinoHelper;
import com.github.fge.jsonschema.core.util.RegexECMA262Helper;
import com.github.fge.jsonschema.keyword.validator.AbstractKeywordValidator;
import com.github.fge.jsonschema.processors.data.FullData;
import com.github.fge.msgsimple.bundle.MessageBundle;

/**
* Keyword validator for {@code pattern}
*
* @see RhinoHelper
* @see RegexECMA262Helper
*/
public final class PatternValidator
extends AbstractKeywordValidator
Expand All @@ -50,7 +50,7 @@ public void validate(final Processor<FullData, FullData> processor,
final String regex = data.getSchema().getNode().get(keyword)
.textValue();
final String value = data.getInstance().getNode().textValue();
if (!RhinoHelper.regMatch(regex, value))
if (!RegexECMA262Helper.regMatch(regex, value))
report.error(newMsg(data, bundle, "err.common.pattern.noMatch")
.putArgument("regex", regex).putArgument("string", value));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@
final class CustomHelpFormatter
implements HelpFormatter
{
private static final List<String> HELP_PREAMBLE = ImmutableList.of(
private static final ImmutableList<String> HELP_PREAMBLE = ImmutableList.of(
"Syntax:",
" java -jar jsonschema.jar [options] schema file [file...]",
" java -jar jsonschema.jar --syntax [options] schema [schema...]",
"",
"Options: "
);

private static final List<String> HELP_POST
private static final ImmutableList<String> HELP_POST
= ImmutableList.<String>builder()
.add("")
.add("Exit codes:")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.github.fge.jackson.jsonpointer.JsonPointer;
import com.github.fge.jsonschema.core.util.RhinoHelper;
import com.github.fge.jsonschema.core.util.RegexECMA262Helper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;

Expand Down Expand Up @@ -73,7 +73,7 @@ public Iterable<JsonPointer> selectSchemas(final String memberName)
list.add(PROPERTIES.append(memberName));

for (final String regex: patternProperties)
if (RhinoHelper.regMatch(regex, memberName))
if (RegexECMA262Helper.regMatch(regex, memberName))
list.add(PATTERNPROPERTIES.append(regex));

if (!list.isEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@
@ParametersAreNonnullByDefault
final class ValidationStack
{
/*
* Sentinel which is always the first element of the stack; we use it in
* order to simplify the pop code.
*/
private static final Element NULL_ELEMENT = new Element(null, null);

/*
* Queue of visited contexts
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import static com.github.fge.jsonschema.TestUtils.anyReport;
import static com.github.fge.jsonschema.TestUtils.onlyOnce;
import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
Expand Down Expand Up @@ -247,6 +247,7 @@ private DummyProcessor(final WantedState wanted1,
}

@Override
@SuppressWarnings("ReferenceEquality")
public FullData process(final ProcessingReport report,
final FullData input)
throws ProcessingException
Expand Down

0 comments on commit 9a98166

Please sign in to comment.