Showing 12 of 22 total issues
File StateManager.java
has 305 lines of code (exceeds 250 allowed). Consider refactoring. Open
package com.devshawn.kafka.gitops;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import com.devshawn.kafka.gitops.config.KafkaGitopsConfig;
Method planTopics
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void planTopics(DesiredState desiredState, DesiredPlan.Builder desiredPlan) {
Map<String, TopicDescription> topics = kafkaService.getTopics();
List<String> topicNames = topics.entrySet().stream().map(Map.Entry::getKey).collect(Collectors.toList());
Map<String, List<ConfigEntry>> topicConfigs = fetchTopicConfigurations(topicNames);
Method planTopicConfigurations
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void planTopicConfigurations(String topicName, TopicDetails topicDetails, List<ConfigEntry> configs, TopicPlan.Builder topicPlan) {
Map<String, TopicConfigPlan> configPlans = new HashMap<>();
List<ConfigEntry> customConfigs = configs == null ? new ArrayList<>() : configs.stream()
.filter(it -> it.source() == ConfigEntry.ConfigSource.DYNAMIC_TOPIC_CONFIG)
.collect(Collectors.toList());
Method updateTopicReplication
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void updateTopicReplication(Collection<Node> clusterNodes, String topicName, Integer integer) {
try (final AdminClient adminClient = buildAdminClient()) {
Map<String, TopicDescription> originalTopicDescription = getTopicDescription(Collections.singleton(topicName));
Map<TopicPartition, Optional<NewPartitionReassignment>> newReasignement = new HashMap<>();
originalTopicDescription.values().forEach(topicDescription -> {
Method planAcls
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void planAcls(DesiredState desiredState, DesiredPlan.Builder desiredPlan) {
List<AclBinding> currentAcls = kafkaService.getAcls();
currentAcls.forEach(acl -> {
Map.Entry<String, AclDetails> detailsEntry = desiredState.getAcls().entrySet().stream()
Method parseStateFile
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public DesiredStateFile parseStateFile(File stateFile) {
log.info("Parsing desired state file...");
try {
return objectMapper.readValue(stateFile, DesiredStateFile.class);
Method printTopicDetailsPlan
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private static void printTopicDetailsPlan(TopicDetailsPlan topicDetailsPlan) {
switch (topicDetailsPlan.getPartitionsAction()) {
case ADD:
System.out.println(green(String.format("\t+ partitions: %s", topicDetailsPlan.getPartitions().get())));
break;
Consider simplifying this complex logical expression. Open
if (aclBinding.pattern().name().equals(getName())
&& aclBinding.pattern().patternType().name().equals(getPattern())
&& aclBinding.pattern().resourceType().name().equals(getType())
&& aclBinding.entry().principal().equals(getPrincipal())
&& aclBinding.entry().host().equals(getHost())
Method parseStateFile
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public DesiredStateFile parseStateFile() {
DesiredStateFile desiredStateFile = parseStateFile(file);
if (desiredStateFile.getSettings().isPresent() && desiredStateFile.getSettings().get().getFiles().isPresent()) {
DesiredStateFile.Builder builder = new DesiredStateFile.Builder().mergeFrom(desiredStateFile);
SettingsFiles settingsFiles = desiredStateFile.getSettings().get().getFiles().get();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method handleAuthentication
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private static void handleAuthentication(AtomicReference<String> username, AtomicReference<String> password, Map<String, Object> config) {
if (username.get() != null && password.get() != null) {
// Do we need the Plain or SCRAM module?
String loginModule = null;
if (config.get(SaslConfigs.SASL_MECHANISM).equals("PLAIN")) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method parseStateFile
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public DesiredStateFile parseStateFile(File stateFile) {
log.info("Parsing desired state file...");
try {
return objectMapper.readValue(stateFile, DesiredStateFile.class);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method toChangesOnlyPlan
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static Optional<TopicDetailsPlan> toChangesOnlyPlan(Optional<TopicDetailsPlan> topicDetailsPlan) {
if(! topicDetailsPlan.isPresent()) {
return topicDetailsPlan;
}
TopicDetailsPlan.Builder builder = new TopicDetailsPlan.Builder();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"