Skip to content

Commit 9a98166

Browse files
committed
Fix ErrorProne and deprecated warnings.
Couldn't figure out the reference equality issues in CallbackValidatorTest, so I suppressed it.
1 parent 49ecb1a commit 9a98166

File tree

11 files changed

+21
-25
lines changed

11 files changed

+21
-25
lines changed

src/main/java/com/github/fge/jsonschema/exceptions/InvalidInstanceException.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
public final class InvalidInstanceException
2929
extends ProcessingException
3030
{
31+
private static final long serialVersionUID = -3273787152985150466L;
32+
3133
public InvalidInstanceException(final ProcessingMessage message)
3234
{
3335
super(message);

src/main/java/com/github/fge/jsonschema/format/common/DateTimeAttribute.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
import org.joda.time.format.DateTimeFormatterBuilder;
3232
import org.joda.time.format.DateTimeParser;
3333

34-
import java.util.List;
35-
3634
import static org.joda.time.DateTimeFieldType.*;
3735

3836
/**
@@ -41,7 +39,7 @@
4139
public final class DateTimeAttribute
4240
extends AbstractFormatAttribute
4341
{
44-
private static final List<String> FORMATS = ImmutableList.of(
42+
private static final ImmutableList<String> FORMATS = ImmutableList.of(
4543
"yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-MM-dd'T'HH:mm:ss.[0-9]{1,12}Z"
4644
);
4745
private static final DateTimeFormatter FORMATTER;

src/main/java/com/github/fge/jsonschema/format/common/RFC3339DateTimeAttribute.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.github.fge.jsonschema.format.common;
22

3-
import java.util.List;
4-
53
import com.github.fge.jsonschema.cfg.ValidationConfiguration;
64
import com.github.fge.jsonschema.library.DraftV4Library;
75
import org.joda.time.format.DateTimeFormatter;
@@ -31,7 +29,7 @@
3129
*/
3230
public class RFC3339DateTimeAttribute extends AbstractFormatAttribute {
3331

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

src/main/java/com/github/fge/jsonschema/format/common/RegexAttribute.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import com.github.fge.jackson.NodeType;
2323
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
2424
import com.github.fge.jsonschema.core.report.ProcessingReport;
25-
import com.github.fge.jsonschema.core.util.RhinoHelper;
25+
import com.github.fge.jsonschema.core.util.RegexECMA262Helper;
2626
import com.github.fge.jsonschema.format.AbstractFormatAttribute;
2727
import com.github.fge.jsonschema.format.FormatAttribute;
2828
import com.github.fge.jsonschema.processors.data.FullData;
@@ -34,7 +34,7 @@
3434
* <p>Again, here, we do <b>not</b> use {@link java.util.regex} because it does
3535
* not fit the bill.</p>
3636
*
37-
* @see RhinoHelper
37+
* @see RegexECMA262Helper
3838
*/
3939
public final class RegexAttribute
4040
extends AbstractFormatAttribute
@@ -58,7 +58,7 @@ public void validate(final ProcessingReport report,
5858
{
5959
final String value = data.getInstance().getNode().textValue();
6060

61-
if (!RhinoHelper.regexIsValid(value))
61+
if (!RegexECMA262Helper.regexIsValid(value))
6262
report.error(newMsg(data, bundle, "err.format.invalidRegex")
6363
.putArgument("value", value));
6464
}

src/main/java/com/github/fge/jsonschema/keyword/digest/draftv3/DraftV3DependenciesDigester.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ public JsonNode digest(final JsonNode schema)
9191
case STRING:
9292
propertyDeps.put(key, FACTORY.arrayNode()
9393
.add(value.textValue()));
94+
break;
95+
default:
96+
break;
9497
}
9598
}
9699

src/main/java/com/github/fge/jsonschema/keyword/validator/common/AdditionalPropertiesValidator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
2626
import com.github.fge.jsonschema.core.processing.Processor;
2727
import com.github.fge.jsonschema.core.report.ProcessingReport;
28-
import com.github.fge.jsonschema.core.util.RhinoHelper;
28+
import com.github.fge.jsonschema.core.util.RegexECMA262Helper;
2929
import com.github.fge.jsonschema.keyword.validator.AbstractKeywordValidator;
3030
import com.github.fge.jsonschema.processors.data.FullData;
3131
import com.github.fge.msgsimple.bundle.MessageBundle;
@@ -84,7 +84,7 @@ public void validate(final Processor<FullData, FullData> processor,
8484

8585
for (final String field: fields)
8686
for (final String regex: patternProperties)
87-
if (RhinoHelper.regMatch(regex, field))
87+
if (RegexECMA262Helper.regMatch(regex, field))
8888
tmp.add(field);
8989

9090
fields.removeAll(tmp);

src/main/java/com/github/fge/jsonschema/keyword/validator/common/PatternValidator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
2424
import com.github.fge.jsonschema.core.processing.Processor;
2525
import com.github.fge.jsonschema.core.report.ProcessingReport;
26-
import com.github.fge.jsonschema.core.util.RhinoHelper;
26+
import com.github.fge.jsonschema.core.util.RegexECMA262Helper;
2727
import com.github.fge.jsonschema.keyword.validator.AbstractKeywordValidator;
2828
import com.github.fge.jsonschema.processors.data.FullData;
2929
import com.github.fge.msgsimple.bundle.MessageBundle;
3030

3131
/**
3232
* Keyword validator for {@code pattern}
3333
*
34-
* @see RhinoHelper
34+
* @see RegexECMA262Helper
3535
*/
3636
public final class PatternValidator
3737
extends AbstractKeywordValidator
@@ -50,7 +50,7 @@ public void validate(final Processor<FullData, FullData> processor,
5050
final String regex = data.getSchema().getNode().get(keyword)
5151
.textValue();
5252
final String value = data.getInstance().getNode().textValue();
53-
if (!RhinoHelper.regMatch(regex, value))
53+
if (!RegexECMA262Helper.regMatch(regex, value))
5454
report.error(newMsg(data, bundle, "err.common.pattern.noMatch")
5555
.putArgument("regex", regex).putArgument("string", value));
5656
}

src/main/java/com/github/fge/jsonschema/main/cli/CustomHelpFormatter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@
3434
final class CustomHelpFormatter
3535
implements HelpFormatter
3636
{
37-
private static final List<String> HELP_PREAMBLE = ImmutableList.of(
37+
private static final ImmutableList<String> HELP_PREAMBLE = ImmutableList.of(
3838
"Syntax:",
3939
" java -jar jsonschema.jar [options] schema file [file...]",
4040
" java -jar jsonschema.jar --syntax [options] schema [schema...]",
4141
"",
4242
"Options: "
4343
);
4444

45-
private static final List<String> HELP_POST
45+
private static final ImmutableList<String> HELP_POST
4646
= ImmutableList.<String>builder()
4747
.add("")
4848
.add("Exit codes:")

src/main/java/com/github/fge/jsonschema/processors/validation/ObjectSchemaSelector.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import com.fasterxml.jackson.databind.JsonNode;
2323
import com.github.fge.jackson.jsonpointer.JsonPointer;
24-
import com.github.fge.jsonschema.core.util.RhinoHelper;
24+
import com.github.fge.jsonschema.core.util.RegexECMA262Helper;
2525
import com.google.common.collect.ImmutableList;
2626
import com.google.common.collect.Lists;
2727

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

7575
for (final String regex: patternProperties)
76-
if (RhinoHelper.regMatch(regex, memberName))
76+
if (RegexECMA262Helper.regMatch(regex, memberName))
7777
list.add(PATTERNPROPERTIES.append(regex));
7878

7979
if (!list.isEmpty())

src/main/java/com/github/fge/jsonschema/processors/validation/ValidationStack.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@
5858
@ParametersAreNonnullByDefault
5959
final class ValidationStack
6060
{
61-
/*
62-
* Sentinel which is always the first element of the stack; we use it in
63-
* order to simplify the pop code.
64-
*/
65-
private static final Element NULL_ELEMENT = new Element(null, null);
66-
6761
/*
6862
* Queue of visited contexts
6963
*/

src/test/java/com/github/fge/jsonschema/keyword/validator/callback/CallbackValidatorTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import static com.github.fge.jsonschema.TestUtils.anyReport;
2323
import static com.github.fge.jsonschema.TestUtils.onlyOnce;
24-
import static org.mockito.Matchers.any;
24+
import static org.mockito.ArgumentMatchers.any;
2525
import static org.mockito.Mockito.mock;
2626
import static org.mockito.Mockito.spy;
2727
import static org.mockito.Mockito.times;
@@ -247,6 +247,7 @@ private DummyProcessor(final WantedState wanted1,
247247
}
248248

249249
@Override
250+
@SuppressWarnings("ReferenceEquality")
250251
public FullData process(final ProcessingReport report,
251252
final FullData input)
252253
throws ProcessingException

0 commit comments

Comments
 (0)