Skip to content

Commit

Permalink
Please spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
algomaster99 committed Jul 24, 2023
1 parent 91367c9 commit 47f90b5
Show file tree
Hide file tree
Showing 95 changed files with 275 additions and 447 deletions.
4 changes: 1 addition & 3 deletions sorald-api/src/main/java/sorald/api/ProcessorRepository.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package sorald.api;

import sorald.processor.SoraldAbstractProcessor;

import java.util.List;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import sorald.processor.SoraldAbstractProcessor;

/**
* This interfaces describes a repository of processors. Each processor is a class that implements
Expand Down
6 changes: 2 additions & 4 deletions sorald-api/src/main/java/sorald/api/RuleRepository.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package sorald.api;

import sorald.rule.IRuleType;
import sorald.rule.Rule;

import java.util.Collection;

import javax.annotation.Nonnull;
import sorald.rule.IRuleType;
import sorald.rule.Rule;

/**
* This class defines the interface for a repository of rules. It is used by Sorald to find all
Expand Down
5 changes: 2 additions & 3 deletions sorald-api/src/main/java/sorald/event/models/CrashEvent.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package sorald.event.models;

import sorald.event.EventType;
import sorald.event.SoraldEvent;

import java.io.PrintWriter;
import java.io.StringWriter;
import sorald.event.EventType;
import sorald.event.SoraldEvent;

/** Event recording a crash. */
public class CrashEvent implements SoraldEvent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import sorald.event.EventType;
import sorald.event.SoraldEvent;
import sorald.rule.RuleViolation;

import spoon.reflect.declaration.CtElement;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
package sorald.processor;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import sorald.annotations.IncompleteProcessor;
import sorald.annotations.ProcessorAnnotation;
import sorald.event.EventHelper;
import sorald.event.SoraldEventHandler;
import sorald.event.models.CrashEvent;
import sorald.event.models.RepairEvent;
import sorald.rule.RuleViolation;

import spoon.processing.AbstractProcessor;
import spoon.reflect.declaration.CtElement;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/** superclass for all processors */
public abstract class SoraldAbstractProcessor<E extends CtElement> extends AbstractProcessor<E> {
private int maxFixes = Integer.MAX_VALUE;
Expand Down
3 changes: 1 addition & 2 deletions sorald-api/src/main/java/sorald/rule/RuleViolation.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package sorald.rule;

import sorald.Constants;

import java.nio.file.Path;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import sorald.Constants;

/** Representation of a violation of some Sonar rule */
public abstract class RuleViolation implements Comparable<RuleViolation> {
Expand Down
3 changes: 1 addition & 2 deletions sorald-api/src/main/java/sorald/rule/StaticAnalyzer.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package sorald.rule;

import sorald.cli.CLIConfigForStaticAnalyzer;

import java.io.File;
import java.util.Collection;
import java.util.List;
import sorald.cli.CLIConfigForStaticAnalyzer;

/** A static analyzer for Java source code */
public interface StaticAnalyzer {
Expand Down
6 changes: 2 additions & 4 deletions sorald/src/main/java/sorald/CodeGenerator.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package sorald;

import sorald.sonar.ProcessorsClassGenerator;

import spoon.Launcher;

import java.nio.file.Path;
import java.nio.file.Paths;
import sorald.sonar.ProcessorsClassGenerator;
import spoon.Launcher;

/** Wrapper class for all (present and future) code generation in Sorald. */
public class CodeGenerator {
Expand Down
5 changes: 2 additions & 3 deletions sorald/src/main/java/sorald/Processors.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package sorald;

import sorald.api.ProcessorRepository;
import sorald.processor.SoraldAbstractProcessor;

import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.ServiceLoader;
import java.util.stream.Collectors;
import sorald.api.ProcessorRepository;
import sorald.processor.SoraldAbstractProcessor;

public class Processors {
private Processors() {}
Expand Down
38 changes: 18 additions & 20 deletions sorald/src/main/java/sorald/Repair.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
package sorald;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import sorald.event.EventHelper;
import sorald.event.EventType;
import sorald.event.SoraldEventHandler;
Expand All @@ -11,7 +29,6 @@
import sorald.segment.Node;
import sorald.segment.SoraldTreeBuilderAlgorithm;
import sorald.sonar.BestFitScanner;

import spoon.Launcher;
import spoon.MavenLauncher;
import spoon.compiler.Environment;
Expand All @@ -31,25 +48,6 @@
import spoon.support.QueueProcessingManager;
import spoon.support.sniper.SniperJavaPrettyPrinter;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/** Class for repairing projects. */
public class Repair {
private final SoraldConfig config;
Expand Down
9 changes: 4 additions & 5 deletions sorald/src/main/java/sorald/SelectiveForceImport.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package sorald;

import spoon.reflect.path.CtRole;
import spoon.reflect.reference.CtTypeReference;
import spoon.reflect.visitor.ForceImportProcessor;
import spoon.reflect.visitor.LexicalScope;

import java.util.Collection;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Set;
import spoon.reflect.path.CtRole;
import spoon.reflect.reference.CtTypeReference;
import spoon.reflect.visitor.ForceImportProcessor;
import spoon.reflect.visitor.LexicalScope;

/**
* Processor that force-imports type references only if they are not present in the excluded
Expand Down
5 changes: 2 additions & 3 deletions sorald/src/main/java/sorald/SoraldConfig.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package sorald;

import sorald.cli.CLIConfigForStaticAnalyzer;
import sorald.rule.Rule;

import java.io.File;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import sorald.cli.CLIConfigForStaticAnalyzer;
import sorald.rule.Rule;

/* All config settings of Sorald should be gathered here */
public class SoraldConfig implements CLIConfigForStaticAnalyzer {
Expand Down
13 changes: 5 additions & 8 deletions sorald/src/main/java/sorald/cli/MineCommand.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package sorald.cli;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.*;
import java.util.stream.Collectors;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.json.JSONObject;

import picocli.CommandLine;

import sorald.Constants;
import sorald.FileUtils;
import sorald.SoraldConfig;
Expand All @@ -22,12 +25,6 @@
import sorald.sonar.SonarRuleType;
import sorald.util.MavenUtils;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.*;
import java.util.stream.Collectors;

/** CLI Command for Sorald's mining functionality. */
@Mojo(name = Constants.MINE_COMMAND_NAME)
@CommandLine.Command(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@

import static sorald.support.IdentityHashSet.newIdentityHashSet;

import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import sorald.event.EventType;
import sorald.event.SoraldEvent;
import sorald.event.SoraldEventHandler;
import sorald.event.models.RepairEvent;

import spoon.reflect.declaration.CtCompilationUnit;
import spoon.reflect.declaration.CtElement;
import spoon.reflect.declaration.CtType;

import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/** Event handler that collects compilation units that receive repairs. */
public class CompilationUnitCollector implements SoraldEventHandler {
private final Map<Path, CtCompilationUnit> pathToCu = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package sorald.event.collectors;

import java.util.*;
import java.util.stream.Collectors;
import sorald.event.SoraldEvent;
import sorald.event.SoraldEventHandler;
import sorald.event.models.WarningLocation;
import sorald.event.models.miner.MinedRule;
import sorald.event.models.miner.MinedViolationEvent;

import java.util.*;
import java.util.stream.Collectors;

/** Event handler for recording the miner mode statistics. */
public class MinerStatisticsCollector implements SoraldEventHandler {
private static final String RULE_ID_SEPARATOR = ":";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package sorald.event.collectors;

import sorald.event.SoraldEvent;
import sorald.event.SoraldEventHandler;
import sorald.event.models.RepairEvent;
import sorald.event.models.miner.MinedViolationEvent;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import sorald.event.SoraldEvent;
import sorald.event.SoraldEventHandler;
import sorald.event.models.RepairEvent;
import sorald.event.models.miner.MinedViolationEvent;

/**
* Event handler for Sorald that collects runtime statistics during execution of the repair command.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package sorald.event.models;

import sorald.rule.RuleViolation;

import java.nio.file.Path;
import sorald.rule.RuleViolation;

public class WarningLocation {
private final String filePath;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package sorald.event.models.miner;

import sorald.event.models.WarningLocation;

import java.util.List;
import sorald.event.models.WarningLocation;

public class MinedRule {
private final String ruleKey;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package sorald.event.models.miner;

import java.nio.file.Path;
import sorald.event.EventType;
import sorald.event.SoraldEvent;
import sorald.event.models.WarningLocation;
import sorald.rule.RuleViolation;
import sorald.sonar.SonarRule;

import java.nio.file.Path;

/** Event representing a mined rule information */
public class MinedViolationEvent implements SoraldEvent {
private final String ruleKey;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
package sorald.event.models.repair;

import sorald.event.collectors.RepairStatisticsCollector;
import sorald.event.models.RepairEvent;
import sorald.event.models.WarningLocation;
import sorald.event.models.miner.MinedViolationEvent;
import sorald.sonar.SonarRule;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
Expand All @@ -14,6 +8,11 @@
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import sorald.event.collectors.RepairStatisticsCollector;
import sorald.event.models.RepairEvent;
import sorald.event.models.WarningLocation;
import sorald.event.models.miner.MinedViolationEvent;
import sorald.sonar.SonarRule;

/** Repair statistics for a single rule. */
public class RuleRepairStatistics {
Expand Down
Loading

0 comments on commit 47f90b5

Please sign in to comment.