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

Basic Nullness Checker configuration #3183

Merged
merged 48 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
c2245e5
Basic Nullness Checker configuration
wmdietl Jun 26, 2023
d1bc0a4
[small] merging 2 string util classes
mattulbrich Jun 26, 2023
018e5fe
Run spotlessApply, add missing Deprecated annotation
wmdietl Jun 26, 2023
2cf9325
Add testComileOnly depencency
wmdietl Jun 26, 2023
763b442
making all classes in util nullness aware
mattulbrich Jun 26, 2023
08673f9
nullness-specifying the StringUtil class
mattulbrich Jun 26, 2023
de7cdae
nullness-specifying class Filenames
mattulbrich Jun 26, 2023
652efd5
nonnull: addressing Werner's review comments
mattulbrich Jun 26, 2023
f95c90b
nullness-specifying some more classes
mattulbrich Jun 26, 2023
28ee001
nullness-specifying some more classes
mattulbrich Jun 27, 2023
c880594
nullness-specifying some more classes
mattulbrich Jun 27, 2023
f489d15
nonnull: adding stub infrastructure
mattulbrich Jun 28, 2023
edc3db2
nullness: continued to specify ImmutableList
mattulbrich Jun 28, 2023
b5b6455
more nullness specifications.
mattulbrich Jun 28, 2023
c9b24c5
wip
mattulbrich Jun 28, 2023
6280b57
nullness checks for ArrayUtil, Beans
mattulbrich Jul 6, 2023
a1b4bd1
nullness and refactoring of class ImmutableSet
mattulbrich Jul 6, 2023
d6b769d
Merge remote-tracking branch 'origin/main' into use-eisop
wadoon Jul 20, 2023
6a62091
JSR305 to jspecify
wadoon Jul 20, 2023
69a19d5
some more annotations
wadoon Jul 21, 2023
17fa5b0
pushing further
wadoon Jul 24, 2023
b4d6dda
Fix type error in KeYCollections.concat
flo2702 Oct 25, 2023
e6bc178
Merge remote-tracking branch 'upstream/main' into use-eisop
flo2702 Oct 27, 2023
ba9dad1
fix compile error
wadoon Nov 3, 2023
9e4f501
spotless
wadoon Nov 3, 2023
266f753
Fix compile errors
flo2702 Nov 8, 2023
860c5e1
Add readme to key.util
flo2702 Nov 8, 2023
3f3c801
Remove unnecessary @NullMarked annotations in @NullMarked packages
flo2702 Nov 8, 2023
4b5e128
Merge remote-tracking branch 'upstream/main' into use-eisop
flo2702 Nov 8, 2023
4d01325
Fix typos in Readme
flo2702 Nov 8, 2023
b7df720
Merge branch 'main' into use-eisop
wadoon Nov 18, 2023
b279636
Merge remote-tracking branch 'upstream/main' into use-eisop
flo2702 Nov 22, 2023
87bb979
Spotless
flo2702 Nov 22, 2023
76a3bd0
Merge branch 'main' into use-eisop
wadoon Dec 29, 2023
5a22f22
Merge branch 'main' into use-eisop
wadoon Feb 11, 2024
46b6744
making the switch working correctly
wadoon Feb 11, 2024
70bb2aa
repair suppres warning
wadoon Feb 11, 2024
cf03cb0
Merge remote-tracking branch 'origin/main' into use-eisop
wadoon Apr 5, 2024
33833f5
Merge branch 'main' into use-eisop
wadoon Apr 23, 2024
e316019
Merge branch 'main' into use-eisop
wadoon Apr 23, 2024
3c818af
Fix merge issues
flo2702 Apr 26, 2024
536d9f8
jspecify was missing in the compile classpath of tests
wadoon Apr 27, 2024
3c6d422
#equals must allow null values
wadoon Apr 27, 2024
9f44bbf
Remove redundant nullness checks and fix test cases
flo2702 Apr 30, 2024
3edb840
Merge remote-tracking branch 'upstream/main' into use-eisop
flo2702 Apr 30, 2024
9870edc
Fix NoSuchElementException in JavaInfo
flo2702 Apr 30, 2024
9b978f9
Fix more NoSuchElementExceptions
flo2702 Apr 30, 2024
1344580
Fix formatting
flo2702 May 2, 2024
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
16 changes: 16 additions & 0 deletions .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ on:
- 'KeY-*'

jobs:
checkerFramework:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 21
distribution: 'corretto'
cache: 'gradle'
- name: Build with Gradle
uses: gradle/gradle-build-action@v2.4.2
with:
arguments: -DENABLE_NULLNESS=true compileTest


qodana:
runs-on: ubuntu-latest
steps:
Expand Down
32 changes: 30 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ plugins {

// Code formatting
id "com.diffplug.spotless" version "6.25.0"

// EISOP Checker Framework
id "org.checkerframework" version "0.6.28"
}

// Configure this project for use inside IntelliJ:
Expand Down Expand Up @@ -53,6 +56,7 @@ subprojects {
apply plugin: "com.diffplug.spotless"
apply plugin: "checkstyle"
apply plugin: "pmd"
apply plugin: "org.checkerframework"

group = rootProject.group
version = rootProject.version
Expand All @@ -71,6 +75,19 @@ subprojects {

dependencies {
implementation("org.slf4j:slf4j-api:2.0.13")
implementation("org.slf4j:slf4j-api:2.0.12")
testImplementation("ch.qos.logback:logback-classic:1.4.8")

//compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.12.0'
//compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.12.0'

compileOnly("org.jspecify:jspecify:0.3.0")
testCompileOnly("org.jspecify:jspecify:0.3.0")
def eisop_version = "3.42.0-eisop2"
compileOnly "io.github.eisop:checker-qual:$eisop_version"
compileOnly "io.github.eisop:checker-util:$eisop_version"
testCompileOnly "io.github.eisop:checker-qual:$eisop_version"
checkerFramework "io.github.eisop:checker:$eisop_version"

testImplementation("ch.qos.logback:logback-classic:1.5.6")
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
Expand All @@ -80,8 +97,6 @@ subprojects {
testCompileOnly 'junit:junit:4.13.2'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.10.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2'

implementation("org.jspecify:jspecify:0.3.0")
}

tasks.withType(JavaCompile) {
Expand Down Expand Up @@ -346,6 +361,19 @@ subprojects {
}
}

// checkerFramework {
// checkers = [
// "org.checkerframework.checker.nullness.NullnessChecker",
// ]
// extraJavacArgs = [
// "-AonlyDefs=^org\\.key_project\\.util",
// "-Xmaxerrs", "10000",
// "-Astubs=$projectDir/src/main/checkerframework",
// "-Werror",
// "-Aversion",
// ]
// }

afterEvaluate { // required so project.description is non-null as set by sub build.gradle
publishing {
publications {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ public static boolean containsSequentFormulasToRefactor(TermLabelState state) {
@SuppressWarnings("unchecked")
Set<SequentFormula> sfSet =
(Set<SequentFormula>) labelState.get(SEQUENT_FORMULA_REFACTORING_REQUIRED);
return !CollectionUtil.isEmpty(sfSet);
return sfSet != null && !sfSet.isEmpty();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4141,7 +4141,7 @@ public static boolean lazyComputeIsAdditionalBranchVerified(Node node) {
Set<Term> additinalPredicates =
AbstractOperationPO.getAdditionalUninterpretedPredicates(node.proof());
// Check if node can be treated as verified/closed
if (!CollectionUtil.isEmpty(additinalPredicates)) {
if (additinalPredicates != null && !additinalPredicates.isEmpty()) {
boolean verified = true;
Iterator<Node> leafsIter = node.leavesIterator();
while (verified && leafsIter.hasNext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public String getDescription() {

@Override
public boolean canApplyTo(Proof proof, ImmutableList<Goal> goals, PosInOccurrence posInOcc) {
if (goals == null || goals.head() == null || goals.head().node() == null
if (goals == null || goals.isEmpty() || goals.head().node() == null
|| goals.head().node().parent() == null) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public String getDescription() {

@Override
public boolean canApplyTo(Proof proof, ImmutableList<Goal> goals, PosInOccurrence posInOcc) {
if (goals == null || goals.head() == null || goals.head().node() == null
if (goals == null || goals.isEmpty() || goals.head().node() == null
|| goals.head().node().parent() == null) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public String getDescription() {

@Override
public boolean canApplyTo(Proof proof, ImmutableList<Goal> goals, PosInOccurrence posInOcc) {
if (goals == null || goals.head() == null) {
if (goals == null || goals.isEmpty()) {
return false;
}
if (posInOcc == null || posInOcc.subTerm() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ private void linkSymbExecVarsToCopies() {
private void linkStateVarsToCopies(StateVars ifVars, StateVars seVars, Map<Term, Term> map) {
final Iterator<Term> ifVarsIt = ifVars.termList.iterator();
for (final Term symbTerm : seVars.termList) {
final Term ifTerm = ifVarsIt.next();
final Term ifTerm;
if (ifVarsIt.hasNext()) {
ifTerm = ifVarsIt.next();
} else {
ifTerm = null;
}
if (symbTerm != null) {
map.put(symbTerm, ifTerm);
}
Expand Down
4 changes: 3 additions & 1 deletion key.core/src/main/java/de/uka/ilkd/key/java/JavaInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,9 @@ public ProgramVariable getAttribute(final String attributeName, Sort s) {
*/
public ProgramVariable getCanonicalFieldProgramVariable(String fieldName, KeYJavaType kjt) {
ImmutableList<ProgramVariable> allAttributes = getAllAttributes(fieldName, kjt, false);
if (kjt.getJavaType() instanceof ArrayType) {
if (allAttributes.isEmpty()) {
return null;
} else if (kjt.getJavaType() instanceof ArrayType) {
return allAttributes.head();
} else {
return allAttributes.reverse().head();
Expand Down
1 change: 0 additions & 1 deletion key.core/src/main/java/de/uka/ilkd/key/logic/Choice.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: GPL-2.0-only */
package de.uka.ilkd.key.logic;


import java.util.List;
import java.util.Objects;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.antlr.v4.runtime.misc.ParseCancellationException;
import org.antlr.v4.runtime.tree.TerminalNode;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -37,6 +38,7 @@
* @author Alexander Weigl
* @version 1 (19.08.19)
*/
@NullMarked
public final class ParsingFacade {
private static final Logger LOGGER = LoggerFactory.getLogger(ParsingFacade.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import org.key_project.logic.Name;
import org.key_project.logic.Named;
import org.key_project.logic.sort.Sort;
import org.key_project.util.collection.DefaultImmutableSet;
import org.key_project.util.collection.ImmutableSet;
import org.key_project.util.collection.Immutables;

import org.antlr.v4.runtime.Token;
import org.slf4j.Logger;
Expand Down Expand Up @@ -147,9 +147,9 @@ public Object visitOne_sort_decl(KeYParser.One_sort_declContext ctx) {
Name sortName = new Name(sortId);

ImmutableSet<Sort> ext = sortExt == null ? ImmutableSet.empty()
: DefaultImmutableSet.fromCollection(sortExt);
: Immutables.createSetFrom(sortExt);
ImmutableSet<Sort> oneOf = sortOneOf == null ? ImmutableSet.empty()
: DefaultImmutableSet.fromCollection(sortOneOf);
: Immutables.createSetFrom(sortOneOf);

// attention: no expand to java.lang here!
Sort existingSort = sorts().lookup(sortName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@

import org.key_project.logic.Name;
import org.key_project.logic.sort.Sort;
import org.key_project.util.collection.DefaultImmutableSet;
import org.key_project.util.collection.ImmutableList;
import org.key_project.util.collection.ImmutableSLList;
import org.key_project.util.collection.ImmutableSet;
import org.key_project.util.collection.Pair;
import org.key_project.util.collection.*;

import antlr.RecognitionException;
import org.antlr.v4.runtime.ParserRuleContext;
Expand Down Expand Up @@ -740,7 +736,7 @@ public Object visitAddrules(KeYParser.AddrulesContext ctx) {
@Override
public ImmutableSet<SchemaVariable> visitAddprogvar(KeYParser.AddprogvarContext ctx) {
final Collection<? extends SchemaVariable> accept = accept(ctx.pvs);
return ImmutableSet.fromSet(new HashSet<>(Objects.requireNonNull(accept)));
return Immutables.<SchemaVariable>createSetFrom(Objects.requireNonNull(accept));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: GPL-2.0-only */
package de.uka.ilkd.key.parser;


import de.uka.ilkd.key.util.parsing.HasLocation;

import org.jspecify.annotations.Nullable;
Expand Down
Loading
Loading