style: resolve some FCBL_FIELD_COULD_BE_LOCAL warnings (#5764)

style: make simple fields local
This commit is contained in:
Piotr Idzik
2024-10-13 17:16:10 +02:00
committed by GitHub
parent 9b52ac9633
commit ebc3cd2233
5 changed files with 6 additions and 16 deletions

View File

@ -6,7 +6,6 @@ import java.util.Scanner;
class Cycle { class Cycle {
private final int nodes; private final int nodes;
private final int edges;
private int[][] adjacencyMatrix; private int[][] adjacencyMatrix;
private boolean[] visited; private boolean[] visited;
ArrayList<ArrayList<Integer>> cycles = new ArrayList<ArrayList<Integer>>(); ArrayList<ArrayList<Integer>> cycles = new ArrayList<ArrayList<Integer>>();
@ -16,7 +15,7 @@ class Cycle {
System.out.print("Enter the no. of nodes: "); System.out.print("Enter the no. of nodes: ");
nodes = in.nextInt(); nodes = in.nextInt();
System.out.print("Enter the no. of Edges: "); System.out.print("Enter the no. of Edges: ");
edges = in.nextInt(); final int edges = in.nextInt();
adjacencyMatrix = new int[nodes][nodes]; adjacencyMatrix = new int[nodes][nodes];
visited = new boolean[nodes]; visited = new boolean[nodes];

View File

@ -25,8 +25,6 @@ public class CRCAlgorithm {
private ArrayList<Integer> message; private ArrayList<Integer> message;
private ArrayList<Integer> dividedMessage;
private ArrayList<Integer> p; private ArrayList<Integer> p;
private Random randomGenerator; private Random randomGenerator;
@ -44,7 +42,6 @@ public class CRCAlgorithm {
messageChanged = false; messageChanged = false;
message = new ArrayList<>(); message = new ArrayList<>();
messSize = size; messSize = size;
dividedMessage = new ArrayList<>();
p = new ArrayList<>(); p = new ArrayList<>();
for (int i = 0; i < str.length(); i++) { for (int i = 0; i < str.length(); i++) {
p.add(Character.getNumericValue(str.charAt(i))); p.add(Character.getNumericValue(str.charAt(i)));
@ -103,7 +100,6 @@ public class CRCAlgorithm {
public void refactor() { public void refactor() {
messageChanged = false; messageChanged = false;
message = new ArrayList<>(); message = new ArrayList<>();
dividedMessage = new ArrayList<>();
} }
/** /**
@ -156,7 +152,7 @@ public class CRCAlgorithm {
} }
} }
} }
dividedMessage = (ArrayList<Integer>) x.clone(); ArrayList<Integer> dividedMessage = (ArrayList<Integer>) x.clone();
if (!check) { if (!check) {
message.addAll(dividedMessage); message.addAll(dividedMessage);
} else { } else {

View File

@ -259,14 +259,12 @@ class Task1 {
class Task2 { class Task2 {
private int[] a;
public Node sortByHeapSort(Node head) { public Node sortByHeapSort(Node head) {
if (head == null || head.next == null) { if (head == null || head.next == null) {
return head; return head;
} }
int c = count(head); int c = count(head);
a = new int[c]; int[] a = new int[c];
// Array of size c is created // Array of size c is created
int i = 0; int i = 0;
for (Node ptr = head; ptr != null; ptr = ptr.next) { for (Node ptr = head; ptr != null; ptr = ptr.next) {

View File

@ -9,14 +9,12 @@ import org.junit.jupiter.api.Test;
public class A5CipherTest { public class A5CipherTest {
private A5Cipher a5Cipher; private A5Cipher a5Cipher;
private BitSet sessionKey;
private BitSet frameCounter;
@BeforeEach @BeforeEach
void setUp() { void setUp() {
// Initialize the session key and frame counter // Initialize the session key and frame counter
sessionKey = BitSet.valueOf(new long[] {0b1010101010101010L}); final var sessionKey = BitSet.valueOf(new long[] {0b1010101010101010L});
frameCounter = BitSet.valueOf(new long[] {0b0000000000000001L}); final var frameCounter = BitSet.valueOf(new long[] {0b0000000000000001L});
a5Cipher = new A5Cipher(sessionKey, frameCounter); a5Cipher = new A5Cipher(sessionKey, frameCounter);
} }

View File

@ -12,7 +12,6 @@ import org.junit.jupiter.api.Test;
public class A5KeyStreamGeneratorTest { public class A5KeyStreamGeneratorTest {
private A5KeyStreamGenerator keyStreamGenerator; private A5KeyStreamGenerator keyStreamGenerator;
private BitSet sessionKey;
private BitSet frameCounter; private BitSet frameCounter;
@BeforeEach @BeforeEach
@ -20,7 +19,7 @@ public class A5KeyStreamGeneratorTest {
keyStreamGenerator = new A5KeyStreamGenerator(); keyStreamGenerator = new A5KeyStreamGenerator();
// Initialize session key and frame counter for testing // Initialize session key and frame counter for testing
sessionKey = BitSet.valueOf(new long[] {0b1010101010101010L}); // Example 16-bit key final var sessionKey = BitSet.valueOf(new long[] {0b1010101010101010L}); // Example 16-bit key
frameCounter = BitSet.valueOf(new long[] {0b0000000000000001L}); // Example 16-bit frame counter frameCounter = BitSet.valueOf(new long[] {0b0000000000000001L}); // Example 16-bit frame counter
keyStreamGenerator.initialize(sessionKey, frameCounter); keyStreamGenerator.initialize(sessionKey, frameCounter);
} }