style: enable RedundantModifier in checkstyle (#5140)

This commit is contained in:
Piotr Idzik
2024-05-03 21:10:49 +02:00
committed by GitHub
parent 1e2d7e9431
commit b3903f5768
38 changed files with 59 additions and 59 deletions

View File

@ -148,7 +148,7 @@
<!-- Modifier Checks --> <!-- Modifier Checks -->
<!-- See https://checkstyle.org/checks/modifier/index.html --> <!-- See https://checkstyle.org/checks/modifier/index.html -->
<module name="ModifierOrder"/> <module name="ModifierOrder"/>
<!-- TODO <module name="RedundantModifier"/> --> <module name="RedundantModifier"/>
<!-- Checks for blocks. You know, those {}'s --> <!-- Checks for blocks. You know, those {}'s -->
<!-- See https://checkstyle.org/checks/blocks/index.html --> <!-- See https://checkstyle.org/checks/blocks/index.html -->

View File

@ -80,7 +80,7 @@ public class Bag<Element> implements Iterable<Element> {
private Node<Element> currentElement; private Node<Element> currentElement;
public ListIterator(Node<Element> firstElement) { ListIterator(Node<Element> firstElement) {
currentElement = firstElement; currentElement = firstElement;
} }

View File

@ -42,7 +42,7 @@ public class BloomFilter<T> {
int index; int index;
public Hash(int index) { Hash(int index) {
this.index = index; this.index = index;
} }

View File

@ -43,7 +43,7 @@ public class CircularBuffer<Item> {
private int pointer; private int pointer;
private final int max; private final int max;
public CircularPointer(int pointer, int max) { CircularPointer(int pointer, int max) {
this.pointer = pointer; this.pointer = pointer;
this.max = max; this.max = max;
} }

View File

@ -17,7 +17,7 @@ public class LFUCache<K, V> {
private Node previous; private Node previous;
private Node next; private Node next;
public Node(K key, V value, int frequency) { Node(K key, V value, int frequency) {
this.key = key; this.key = key;
this.value = value; this.value = value;
this.frequency = frequency; this.frequency = frequency;

View File

@ -126,10 +126,10 @@ public class LRUCache<K, V> {
private I key; private I key;
private J value; private J value;
public Entry() { Entry() {
} }
public Entry(Entry<I, J> preEntry, Entry<I, J> nextEntry, I key, J value) { Entry(Entry<I, J> preEntry, Entry<I, J> nextEntry, I key, J value) {
this.preEntry = preEntry; this.preEntry = preEntry;
this.nextEntry = nextEntry; this.nextEntry = nextEntry;
this.key = key; this.key = key;

View File

@ -124,10 +124,10 @@ public class MRUCache<K, V> {
private I key; private I key;
private J value; private J value;
public Entry() { Entry() {
} }
public Entry(Entry<I, J> preEntry, Entry<I, J> nextEntry, I key, J value) { Entry(Entry<I, J> preEntry, Entry<I, J> nextEntry, I key, J value) {
this.preEntry = preEntry; this.preEntry = preEntry;
this.nextEntry = nextEntry; this.nextEntry = nextEntry;
this.key = key; this.key = key;

View File

@ -26,7 +26,7 @@ class GCounter {
* *
* @param n The number of nodes in the cluster. * @param n The number of nodes in the cluster.
*/ */
public GCounter(int myId, int n) { GCounter(int myId, int n) {
this.myId = myId; this.myId = myId;
this.n = n; this.n = n;
this.P = new HashMap<>(); this.P = new HashMap<>();

View File

@ -26,7 +26,7 @@ class Element {
* @param timestamp The timestamp associated with the element. * @param timestamp The timestamp associated with the element.
* @param bias The bias of the element (ADDS or REMOVALS). * @param bias The bias of the element (ADDS or REMOVALS).
*/ */
public Element(String key, int timestamp, Bias bias) { Element(String key, int timestamp, Bias bias) {
this.key = key; this.key = key;
this.timestamp = timestamp; this.timestamp = timestamp;
this.bias = bias; this.bias = bias;
@ -49,7 +49,7 @@ class LWWElementSet {
/** /**
* Constructs an empty LWWElementSet. * Constructs an empty LWWElementSet.
*/ */
public LWWElementSet() { LWWElementSet() {
this.addSet = new HashMap<>(); this.addSet = new HashMap<>();
this.removeSet = new HashMap<>(); this.removeSet = new HashMap<>();
} }

View File

@ -28,7 +28,7 @@ class PNCounter {
* @param myId The identifier of the current node. * @param myId The identifier of the current node.
* @param n The number of nodes in the cluster. * @param n The number of nodes in the cluster.
*/ */
public PNCounter(int myId, int n) { PNCounter(int myId, int n) {
this.myId = myId; this.myId = myId;
this.n = n; this.n = n;
this.P = new HashMap<>(); this.P = new HashMap<>();

View File

@ -14,7 +14,7 @@ public class A_Star {
private ArrayList<ArrayList<Edge>> graph; private ArrayList<ArrayList<Edge>> graph;
// Initialise ArrayLists in Constructor // Initialise ArrayLists in Constructor
public Graph(int size) { Graph(int size) {
this.graph = new ArrayList<>(); this.graph = new ArrayList<>();
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
this.graph.add(new ArrayList<>()); this.graph.add(new ArrayList<>());
@ -38,7 +38,7 @@ public class A_Star {
private int to; private int to;
private int weight; private int weight;
public Edge(int from, int to, int weight) { Edge(int from, int to, int weight) {
this.from = from; this.from = from;
this.to = to; this.to = to;
this.weight = weight; this.weight = weight;
@ -64,7 +64,7 @@ public class A_Star {
private ArrayList<Integer> path; // list of visited nodes in this path. private ArrayList<Integer> path; // list of visited nodes in this path.
private int estimated; // heuristic value associated to the last node od the path (current node). private int estimated; // heuristic value associated to the last node od the path (current node).
public PathAndDistance(int distance, ArrayList<Integer> path, int estimated) { PathAndDistance(int distance, ArrayList<Integer> path, int estimated) {
this.distance = distance; this.distance = distance;
this.path = path; this.path = path;
this.estimated = estimated; this.estimated = estimated;

View File

@ -31,7 +31,7 @@ class BellmanFord /*
* @param v End vertex * @param v End vertex
* @param c Weight * @param c Weight
*/ */
public Edge(int a, int b, int c) { Edge(int a, int b, int c) {
u = a; u = a;
v = b; v = b;
w = c; w = c;

View File

@ -15,7 +15,7 @@ class Graph<E extends Comparable<E>> {
E name; E name;
public Node(E name) { Node(E name) {
this.name = name; this.name = name;
} }
} }
@ -24,7 +24,7 @@ class Graph<E extends Comparable<E>> {
Node startNode, endNode; Node startNode, endNode;
public Edge(Node startNode, Node endNode) { Edge(Node startNode, Node endNode) {
this.startNode = startNode; this.startNode = startNode;
this.endNode = endNode; this.endNode = endNode;
} }
@ -33,7 +33,7 @@ class Graph<E extends Comparable<E>> {
ArrayList<Edge> edgeList; ArrayList<Edge> edgeList;
ArrayList<Node> nodeList; ArrayList<Node> nodeList;
public Graph() { Graph() {
edgeList = new ArrayList<Edge>(); edgeList = new ArrayList<Edge>();
nodeList = new ArrayList<Node>(); nodeList = new ArrayList<Node>();
} }

View File

@ -10,7 +10,7 @@ class Cycle {
private boolean[] visited; private boolean[] visited;
ArrayList<ArrayList<Integer>> cycles = new ArrayList<ArrayList<Integer>>(); ArrayList<ArrayList<Integer>> cycles = new ArrayList<ArrayList<Integer>>();
public Cycle() { Cycle() {
Scanner in = new Scanner(System.in); Scanner in = new Scanner(System.in);
System.out.print("Enter the no. of nodes: "); System.out.print("Enter the no. of nodes: ");
nodes = in.nextInt(); nodes = in.nextInt();

View File

@ -6,7 +6,7 @@ class AdjacencyListGraph<E extends Comparable<E>> {
ArrayList<Vertex> vertices; ArrayList<Vertex> vertices;
public AdjacencyListGraph() { AdjacencyListGraph() {
vertices = new ArrayList<>(); vertices = new ArrayList<>();
} }
@ -15,7 +15,7 @@ class AdjacencyListGraph<E extends Comparable<E>> {
E data; E data;
ArrayList<Vertex> adjacentVertices; ArrayList<Vertex> adjacentVertices;
public Vertex(E data) { Vertex(E data) {
adjacentVertices = new ArrayList<>(); adjacentVertices = new ArrayList<>();
this.data = data; this.data = data;
} }

View File

@ -23,7 +23,7 @@ public class Kruskal {
private int to; private int to;
private int weight; private int weight;
public Edge(int from, int to, int weight) { Edge(int from, int to, int weight) {
this.from = from; this.from = from;
this.to = to; this.to = to;
this.weight = weight; this.weight = weight;

View File

@ -68,7 +68,7 @@ class AdjacencyMatrixGraph {
/** /**
* Constructor * Constructor
*/ */
public AdjacencyMatrixGraph(int givenNumberOfVertices) { AdjacencyMatrixGraph(int givenNumberOfVertices) {
this.setNumberOfVertices(givenNumberOfVertices); this.setNumberOfVertices(givenNumberOfVertices);
this.setNumberOfEdges(0); this.setNumberOfEdges(0);
this.setAdjacency(new int[givenNumberOfVertices][givenNumberOfVertices]); this.setAdjacency(new int[givenNumberOfVertices][givenNumberOfVertices]);

View File

@ -105,7 +105,7 @@ public class GenericHashMapUsingArrayList<K, V> {
K key; K key;
V val; V val;
public Node(K key, V val) { Node(K key, V val) {
this.key = key; this.key = key;
this.val = val; this.val = val;
} }

View File

@ -110,7 +110,7 @@ class Link {
* *
* @param value Value of node * @param value Value of node
*/ */
public Link(int value) { Link(int value) {
this.value = value; this.value = value;
} }

View File

@ -222,7 +222,7 @@ public class SkipList<E extends Comparable<E>> {
private final List<Node<E>> backward; private final List<Node<E>> backward;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Node(E value, int height) { Node(E value, int height) {
this.value = value; this.value = value;
this.height = height; this.height = height;

View File

@ -11,15 +11,15 @@ public class LinkedQueue<T> implements Iterable<T> {
T data; T data;
Node<T> next; Node<T> next;
public Node() { Node() {
this(null); this(null);
} }
public Node(T data) { Node(T data) {
this(data, null); this(data, null);
} }
public Node(T data, Node<T> next) { Node(T data, Node<T> next) {
this.data = data; this.data = data;
this.next = next; this.next = next;
} }

View File

@ -30,7 +30,7 @@ class PriorityQueue {
* Default Constructor * Default Constructor
*/ */
public PriorityQueue() { PriorityQueue() {
/* If capacity is not defined, default size of 11 would be used /* If capacity is not defined, default size of 11 would be used
* capacity=max+1 because we cant access 0th element of PQ, and to * capacity=max+1 because we cant access 0th element of PQ, and to
* accomodate (max)th elements we need capacity to be max+1. * accomodate (max)th elements we need capacity to be max+1.
@ -50,7 +50,7 @@ class PriorityQueue {
* @param size Size of the queue * @param size Size of the queue
*/ */
public PriorityQueue(int size) { PriorityQueue(int size) {
maxSize = size + 1; maxSize = size + 1;
queueArray = new int[maxSize]; queueArray = new int[maxSize];
nItems = 0; nItems = 0;

View File

@ -38,7 +38,7 @@ class Queue {
/** /**
* init with DEFAULT_CAPACITY * init with DEFAULT_CAPACITY
*/ */
public Queue() { Queue() {
this(DEFAULT_CAPACITY); this(DEFAULT_CAPACITY);
} }
@ -47,7 +47,7 @@ class Queue {
* *
* @param size Size of the new queue * @param size Size of the new queue
*/ */
public Queue(int size) { Queue(int size) {
maxSize = size; maxSize = size;
queueArray = new int[size]; queueArray = new int[size];
front = 0; front = 0;

View File

@ -33,7 +33,7 @@ class Node {
public int data; public int data;
public Node next; public Node next;
public Node(int data) { Node(int data) {
this.data = data; this.data = data;
this.next = null; this.next = null;
} }
@ -60,7 +60,7 @@ class LinkedListStack {
/** /**
* Init properties * Init properties
*/ */
public LinkedListStack() { LinkedListStack() {
head = null; head = null;
size = 0; size = 0;
} }

View File

@ -47,7 +47,7 @@ public class BinaryTree {
* *
* @param value Value to put in the node * @param value Value to put in the node
*/ */
public Node(int value) { Node(int value) {
data = value; data = value;
left = null; left = null;
right = null; right = null;

View File

@ -68,7 +68,7 @@ public class KDTree {
return coordinates.length; return coordinates.length;
} }
public Point(int[] coordinates) { Point(int[] coordinates) {
this.coordinates = coordinates; this.coordinates = coordinates;
} }

View File

@ -15,7 +15,7 @@ public class LazySegmentTree {
private int lazy; // lazied value that should be added to children nodes private int lazy; // lazied value that should be added to children nodes
Node left, right; // left and right children Node left, right; // left and right children
public Node(int start, int end, int value) { Node(int start, int end, int value) {
this.start = start; this.start = start;
this.end = end; this.end = end;
this.value = value; this.value = value;

View File

@ -13,7 +13,7 @@ class TreeNode {
TreeNode left, right; TreeNode left, right;
// Constructor // Constructor
public TreeNode(int key) { TreeNode(int key) {
this.key = key; this.key = key;
left = right = null; left = right = null;
} }
@ -27,7 +27,7 @@ class QItem {
TreeNode node; TreeNode node;
int hd; int hd;
public QItem(TreeNode n, int h) { QItem(TreeNode n, int h) {
node = n; node = n;
hd = h; hd = h;
} }
@ -39,11 +39,11 @@ class Tree {
TreeNode root; TreeNode root;
// Constructors // Constructors
public Tree() { Tree() {
root = null; root = null;
} }
public Tree(TreeNode n) { Tree(TreeNode n) {
root = n; root = n;
} }

View File

@ -53,13 +53,13 @@ class NRKTree {
public NRKTree right; public NRKTree right;
public int data; public int data;
public NRKTree(int x) { NRKTree(int x) {
this.left = null; this.left = null;
this.right = null; this.right = null;
this.data = x; this.data = x;
} }
public NRKTree(NRKTree right, NRKTree left, int x) { NRKTree(NRKTree right, NRKTree left, int x) {
this.left = left; this.left = left;
this.right = right; this.right = right;
this.data = x; this.data = x;

View File

@ -19,7 +19,7 @@ public class JobSequencing {
return otherJob.profit - this.profit; return otherJob.profit - this.profit;
} }
public Job(char id, int deadline, int profit) { Job(char id, int deadline, int profit) {
this.id = id; this.id = id;
this.deadline = deadline; this.deadline = deadline;
this.profit = profit; this.profit = profit;

View File

@ -27,7 +27,7 @@ public class FFT {
/** /**
* Default Constructor. Creates the complex number 0. * Default Constructor. Creates the complex number 0.
*/ */
public Complex() { Complex() {
real = 0; real = 0;
img = 0; img = 0;
} }
@ -38,7 +38,7 @@ public class FFT {
* @param r The real part of the number. * @param r The real part of the number.
* @param i The imaginary part of the number. * @param i The imaginary part of the number.
*/ */
public Complex(double r, double i) { Complex(double r, double i) {
real = r; real = r;
img = i; img = i;
} }

View File

@ -127,7 +127,7 @@ class Trie {
TrieNode root; TrieNode root;
char endSymbol; char endSymbol;
public Trie() { Trie() {
this.root = new TrieNode(); this.root = new TrieNode();
this.endSymbol = '*'; this.endSymbol = '*';
} }

View File

@ -61,7 +61,7 @@ class Graph {
public final String v1, v2; public final String v1, v2;
public final int dist; public final int dist;
public Edge(String v1, String v2, int dist) { Edge(String v1, String v2, int dist) {
this.v1 = v1; this.v1 = v1;
this.v2 = v2; this.v2 = v2;
this.dist = dist; this.dist = dist;
@ -79,7 +79,7 @@ class Graph {
public Vertex previous = null; public Vertex previous = null;
public final Map<Vertex, Integer> neighbours = new HashMap<>(); public final Map<Vertex, Integer> neighbours = new HashMap<>();
public Vertex(String name) { Vertex(String name) {
this.name = name; this.name = name;
} }
@ -147,7 +147,7 @@ class Graph {
/** /**
* Builds a graph from a set of edges * Builds a graph from a set of edges
*/ */
public Graph(Edge[] edges) { Graph(Edge[] edges) {
graph = new HashMap<>(edges.length); graph = new HashMap<>(edges.length);
// one pass to find all vertices // one pass to find all vertices

View File

@ -176,7 +176,7 @@ public class KochSnowflake {
double x, y; double x, y;
public Vector2(double x, double y) { Vector2(double x, double y) {
this.x = x; this.x = x;
this.y = y; this.y = y;
} }

View File

@ -25,7 +25,7 @@ class QueueWithStack {
/** /**
* Constructor * Constructor
*/ */
public QueueWithStack() { QueueWithStack() {
this.inStack = new Stack<>(); this.inStack = new Stack<>();
this.outStack = new Stack<>(); this.outStack = new Stack<>();
} }

View File

@ -11,7 +11,7 @@ public class TopKWords {
private String fileName; private String fileName;
public CountWords(String fileName) { CountWords(String fileName) {
this.fileName = fileName; this.fileName = fileName;
} }

View File

@ -13,7 +13,7 @@ class Process {
int burstTime; int burstTime;
int priority; int priority;
public Process(String name, int arrivalTime, int burstTime, int priority) { Process(String name, int arrivalTime, int burstTime, int priority) {
this.name = name; this.name = name;
this.arrivalTime = arrivalTime; this.arrivalTime = arrivalTime;
this.burstTime = burstTime; this.burstTime = burstTime;

View File

@ -43,7 +43,7 @@ public class TopologicalSort {
* */ * */
public final ArrayList<String> next = new ArrayList<>(); public final ArrayList<String> next = new ArrayList<>();
public Vertex(String label) { Vertex(String label) {
this.label = label; this.label = label;
} }
} }
@ -69,7 +69,7 @@ public class TopologicalSort {
static class BackEdgeException extends RuntimeException { static class BackEdgeException extends RuntimeException {
public BackEdgeException(String backEdge) { BackEdgeException(String backEdge) {
super("This graph contains a cycle. No linear ordering is possible. " + backEdge); super("This graph contains a cycle. No linear ordering is possible. " + backEdge);
} }
} }