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

View File

@ -25,8 +25,6 @@ public class CRCAlgorithm {
private ArrayList<Integer> message;
private ArrayList<Integer> dividedMessage;
private ArrayList<Integer> p;
private Random randomGenerator;
@ -44,7 +42,6 @@ public class CRCAlgorithm {
messageChanged = false;
message = new ArrayList<>();
messSize = size;
dividedMessage = new ArrayList<>();
p = new ArrayList<>();
for (int i = 0; i < str.length(); i++) {
p.add(Character.getNumericValue(str.charAt(i)));
@ -103,7 +100,6 @@ public class CRCAlgorithm {
public void refactor() {
messageChanged = false;
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) {
message.addAll(dividedMessage);
} else {

View File

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

View File

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

View File

@ -12,7 +12,6 @@ import org.junit.jupiter.api.Test;
public class A5KeyStreamGeneratorTest {
private A5KeyStreamGenerator keyStreamGenerator;
private BitSet sessionKey;
private BitSet frameCounter;
@BeforeEach
@ -20,7 +19,7 @@ public class A5KeyStreamGeneratorTest {
keyStreamGenerator = new A5KeyStreamGenerator();
// 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
keyStreamGenerator.initialize(sessionKey, frameCounter);
}