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

Some general minor code quality improvements #3293

Merged
merged 6 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public void add(InstantiationProposer proposer) {

public String getProposal(TacletApp app, SchemaVariable var, Services services, Node undoAnchor,
ImmutableList<String> previousProposals) {
for (InstantiationProposer proposer1 : proposers) {
InstantiationProposer proposer = proposer1;
for (InstantiationProposer proposer : proposers) {
String proposal =
proposer.getProposal(app, var, services, undoAnchor, previousProposals);
if (proposal != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import de.uka.ilkd.key.rule.NoPosTacletApp;
import de.uka.ilkd.key.rule.inst.*;

import org.key_project.util.collection.*;
import org.key_project.util.collection.DefaultImmutableSet;
import org.key_project.util.collection.ImmutableArray;
import org.key_project.util.collection.ImmutableList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package de.uka.ilkd.key.proof;


import java.net.MalformedURLException;
import javax.annotation.Nullable;

import de.uka.ilkd.key.java.Position;
Expand Down Expand Up @@ -61,7 +60,7 @@ public String toString() {

@Nullable
@Override
public Location getLocation() throws MalformedURLException {
public Location getLocation() {
return new Location(null, position);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class TacletAppIndex {
*/
private RuleFilter ruleFilter;

private State state;
private final State state;

private final Map<CacheKey, TermTacletAppIndex> cache;

Expand Down
6 changes: 2 additions & 4 deletions key.core/src/main/java/de/uka/ilkd/key/proof/TacletIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ private ImmutableList<NoPosTacletApp> getListHelp(
* @param second the second list
* @return the merged list
*/
private final ImmutableList<NoPosTacletApp> merge(ImmutableList<NoPosTacletApp> first,
private ImmutableList<NoPosTacletApp> merge(ImmutableList<NoPosTacletApp> first,
final ImmutableList<NoPosTacletApp> second) {
if (second == null) {
return first;
Expand Down Expand Up @@ -579,9 +579,7 @@ private static class PrefixOccurrences {
* resets the occurred field to 'nothing has occurred'
*/
public void reset() {
for (int i = 0; i < PREFIXTYPES; i++) {
occurred[i] = false;
}
Arrays.fill(occurred, 0, PREFIXTYPES, false);
}

/**
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.proof.init;

import java.io.IOException;
import java.util.*;

import de.uka.ilkd.key.java.Services;
Expand Down Expand Up @@ -302,10 +301,8 @@ public void fillSaveProperties(Properties properties) {
* @param initConfig The already load {@link InitConfig}.
* @param properties The settings of the proof obligation to instantiate.
* @return The instantiated proof obligation.
* @throws IOException Occurred Exception.
*/
public static LoadedPOContainer loadFrom(InitConfig initConfig, Properties properties)
throws IOException {
public static LoadedPOContainer loadFrom(InitConfig initConfig, Properties properties) {
String contractName = properties.getProperty("contract");
int proofNum = 0;
String baseContractName = null;
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.proof.init;

import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -80,10 +79,8 @@ public FunctionalBlockContractPO(InitConfig initConfig, FunctionalBlockContract
* @param initConfig The already load {@link InitConfig}.
* @param properties The settings of the proof obligation to instantiate.
* @return The instantiated proof obligation.
* @throws IOException Occurred Exception.
*/
public static LoadedPOContainer loadFrom(InitConfig initConfig, Properties properties)
throws IOException {
public static LoadedPOContainer loadFrom(InitConfig initConfig, Properties properties) {
String contractName = properties.getProperty("contract");
int proofNum = 0;
String baseContractName = null;
Expand Down Expand Up @@ -339,7 +336,7 @@ public boolean equals(Object obj) {
}

@Override
public void readProblem() throws ProofInputException {
public void readProblem() {
assert proofConfig == null;
final boolean makeNamesUnique = true;
final Services services = postInit();
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.proof.init;

import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -80,10 +79,8 @@ public FunctionalLoopContractPO(InitConfig initConfig, FunctionalLoopContract co
* @param initConfig The already load {@link InitConfig}.
* @param properties The settings of the proof obligation to instantiate.
* @return The instantiated proof obligation.
* @throws IOException Occurred Exception.
*/
public static LoadedPOContainer loadFrom(InitConfig initConfig, Properties properties)
throws IOException {
public static LoadedPOContainer loadFrom(InitConfig initConfig, Properties properties) {
String contractName = properties.getProperty("contract");
int proofNum = 0;
String baseContractName = null;
Expand Down Expand Up @@ -161,7 +158,7 @@ public boolean equals(Object obj) {
}

@Override
public void readProblem() throws ProofInputException {
public void readProblem() {
assert proofConfig == null;
final boolean makeNamesUnique = true;
final Services services = postInit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
*/
public class FunctionalOperationContractPO extends AbstractOperationPO implements ContractPO {
public static final Map<Boolean, String> TRANSACTION_TAGS =
new LinkedHashMap<Boolean, String>();
new LinkedHashMap<>();

private final FunctionalOperationContract contract;

Expand Down Expand Up @@ -134,7 +134,7 @@ protected ImmutableList<StatementBlock> buildOperationBlocks(
ImmutableList<LocationVariable> formalParVars, ProgramVariable selfVar,
ProgramVariable resultVar, Services services) {
final StatementBlock[] result = new StatementBlock[4];
final ImmutableArray<Expression> formalArray = new ImmutableArray<Expression>(
final ImmutableArray<Expression> formalArray = new ImmutableArray<>(
formalParVars.toArray(new ProgramVariable[formalParVars.size()]));

if (getContract().getTarget().isConstructor()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public String getProofObligation() {
}

@Override
public ProofAggregate getPO() throws ProofInputException {
public ProofAggregate getPO() {
assert problem != null;
String name = name();
ProofSettings settings = getPreferences();
Expand All @@ -181,7 +181,7 @@ public boolean hasProofScript() {
return getParseContext().findProofScript() != null;
}

public Triple<String, Integer, Integer> readProofScript() throws ProofInputException {
public Triple<String, Integer, Integer> readProofScript() {
return getParseContext().findProofScript();
}

Expand Down Expand Up @@ -240,9 +240,8 @@ public Profile getProfile() {
*
* @return The {@link Profile} defined by the file to load or {@code null} if no {@link Profile}
* is defined by the file.
* @throws Exception Occurred Exception.
*/
private Profile readProfileFromFile() throws Exception {
private Profile readProfileFromFile() {
@Nonnull
ProblemInformation pi = getProblemInformation();
String profileName = pi.getProfile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,7 @@ private void readJava(EnvInput envInput, InitConfig initConfig) throws ProofInpu
final String javaPath = envInput.readJavaPath();
final List<File> classPath = envInput.readClassPath();
final File bootClassPath;
try {
bootClassPath = envInput.readBootClassPath();
} catch (IOException ioe) {
throw new ProofInputException(ioe);
}
bootClassPath = envInput.readBootClassPath();

final Includes includes = envInput.readIncludes();

Expand Down Expand Up @@ -384,8 +380,7 @@ private void populateNamespaces(Proof proof) {
}

// what is the purpose of this method?
private InitConfig determineEnvironment(ProofOblInput po, InitConfig initConfig)
throws ProofInputException {
private InitConfig determineEnvironment(ProofOblInput po, InitConfig initConfig) {
// TODO: what does this actually do?
ProofSettings.DEFAULT_SETTINGS.getChoiceSettings().updateChoices(initConfig.choiceNS(),
false);
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.proof.init;

import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
Expand Down Expand Up @@ -199,13 +198,12 @@ private void register(Variables vars, Services proofServices) {
protected ImmutableSet<ClassAxiom> selectClassAxioms(KeYJavaType kjt) {
ImmutableSet<ClassAxiom> result = DefaultImmutableSet.nil();
for (ClassAxiom axiom : specRepos.getClassAxioms(kjt)) {
if (axiom instanceof ClassAxiom && check instanceof ClassWellDefinedness cwd) {
final ClassAxiom classAxiom = axiom;
if (check instanceof ClassWellDefinedness cwd) {
final String kjtName = cwd.getKJT().getFullName();
final String invName = "in " + cwd.getKJT().getName();
if (!classAxiom.getName().endsWith(invName)
&& !classAxiom.getName().endsWith(kjtName)) {
result = result.add(classAxiom);
if (!axiom.getName().endsWith(invName)
&& !axiom.getName().endsWith(kjtName)) {
result = result.add(axiom);
}
} else {
result = result.add(axiom);
Expand All @@ -227,7 +225,7 @@ public KeYJavaType getKJT() {
}

@Override
public void readProblem() throws ProofInputException {
public void readProblem() {
assert proofConfig == null;

final Services proofServices = postInit();
Expand Down Expand Up @@ -300,10 +298,8 @@ public void fillSaveProperties(Properties properties) {
* @param initConfig The already load {@link InitConfig}.
* @param properties The settings of the proof obligation to instantiate.
* @return The instantiated proof obligation.
* @throws IOException Occurred Exception.
*/
public static LoadedPOContainer loadFrom(InitConfig initConfig, Properties properties)
throws IOException {
public static LoadedPOContainer loadFrom(InitConfig initConfig, Properties properties) {
String contractName = properties.getProperty("wd check");
final Contract contract =
initConfig.getServices().getSpecificationRepository().getContractByName(contractName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package de.uka.ilkd.key.proof.io;

import java.io.File;
import java.io.IOException;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -59,7 +58,6 @@ public interface EnvInput {
return null;
}


/**
* gets the classpath elements to be considered here.
*/
Expand All @@ -68,10 +66,8 @@ public interface EnvInput {

/**
* gets the boot classpath element, null if none set.
*
* @throws
*/
File readBootClassPath() throws IOException;
File readBootClassPath();

/**
* Reads the input using the given modification strategy, i.e., parts of the input do not modify
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import de.uka.ilkd.key.settings.ProofIndependentSMTSettings;
import de.uka.ilkd.key.settings.ProofIndependentSettings;
import de.uka.ilkd.key.smt.*;
import de.uka.ilkd.key.smt.SMTRuleApp;
import de.uka.ilkd.key.smt.SMTSolverResult.ThreeValuedTruth;
import de.uka.ilkd.key.speclang.Contract;
import de.uka.ilkd.key.speclang.OperationContract;
Expand Down
10 changes: 5 additions & 5 deletions key.core/src/main/java/de/uka/ilkd/key/proof/io/LDTInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public interface LDTInputListener {
* creates a representation of the LDT files to be used as input to the KeY prover.
*
* @param keyFiles an array containing the LDT .key files
* @param main the main class used to report the progress of reading
* @param listener an LDTInputListener for stsus reports while loading
* @param profile the Profile for which the LDTs are load
*/
public LDTInput(KeYFile[] keyFiles, LDTInputListener listener, Profile profile) {
assert profile != null;
Expand Down Expand Up @@ -85,14 +86,14 @@ public Includes readIncludes() throws ProofInputException {


@Override
public String readJavaPath() throws ProofInputException {
public String readJavaPath() {
return "";
}


// no class path elements here
@Override
public List<File> readClassPath() throws ProofInputException {
public List<File> readClassPath() {
return null;
}

Expand All @@ -111,7 +112,7 @@ public File readBootClassPath() {
* declared sorts in all rules, e.g.
*/
@Override
public ImmutableSet<PositionedString> read() throws ProofInputException {
public ImmutableSet<PositionedString> read() {
if (initConfig == null) {
throw new IllegalStateException("LDTInput: InitConfig not set.");
}
Expand Down Expand Up @@ -162,7 +163,6 @@ public boolean equals(Object o) {
return true;
}


@Override
public int hashCode() {
int result = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected void save(File file) throws IOException {
save(new FileOutputStream(file));
}

public String save() throws IOException {
public String save() {
String errorMsg = null;
try {
save(file);
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.proof.io.consistency;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
Expand All @@ -19,19 +18,19 @@
public class MemoryFileRepo extends AbstractFileRepo {

@Override
public InputStream getInputStream(Path path) throws IOException {
public InputStream getInputStream(Path path) {
// TODO Auto-generated method stub
return null;
}

@Override
public InputStream getInputStream(RuleSource ruleSource) throws IOException {
public InputStream getInputStream(RuleSource ruleSource) {
// TODO Auto-generated method stub
return null;
}

@Override
public InputStream getInputStream(URL url) throws IOException {
public InputStream getInputStream(URL url) {
// TODO Auto-generated method stub
return null;
}
Expand Down