purbon/kafka-topology-builder

View on GitHub

Showing 167 of 167 total issues

Method retrieve has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  public void retrieve(KafkaBackend callback) {
    int times = 0;
    while (running.get()) {
      ConsumerRecords<String, BackendState> records = consumer.poll(Duration.ofSeconds(10));
      callback.complete();

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 clear has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  public void clear() {
    bindings.clear();
    accounts.clear();
    topics.clear();
    connectors.clear();
Severity: Minor
Found in src/main/java/com/purbon/kafka/topology/backend/BackendState.java - About 25 mins to fix

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

Avoid using a branching statement as the last in a loop.
Open

      continue;

AvoidBranchingStatementAsLastInLoop

Since: PMD 5.0

Priority: Medium High

Categories: Style

Remediation Points: 50000

Using a branching statement as the last part of a loop may be a bug, and/or is confusing. Ensure that the usage is not a bug, or consider using another approach.

Example:

// unusual use of branching statement in a loop
for (int i = 0; i < 10; i++) {
 if (i*i <= 25) {
 continue;
 }
 break;
}

// this makes more sense...
for (int i = 0; i < 10; i++) {
 if (i*i > 25) {
 break;
 }
}

These nested if statements could be combined
Open

      if (!requestPercentage.equals(quota.getRequest_percentage().get())) {
        return true;
      }

CollapsibleIfStatements

Since: PMD 3.1

Priority: Medium

Categories: Style

Remediation Points: 50000

Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator.

Example:

void bar() {
 if (x) { // original implementation
 if (y) {
 // do stuff
 }
 }
}

void bar() {
 if (x && y) { // optimized implementation
 // do stuff
 }
}

These nested if statements could be combined
Open

      if (!consumerByteRate.equals(quota.getConsumer_byte_rate().get())) {
        return true;
      }

CollapsibleIfStatements

Since: PMD 3.1

Priority: Medium

Categories: Style

Remediation Points: 50000

Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator.

Example:

void bar() {
 if (x) { // original implementation
 if (y) {
 // do stuff
 }
 }
}

void bar() {
 if (x && y) { // optimized implementation
 // do stuff
 }
}

These nested if statements could be combined
Open

      if (!elements.contains("key.record.type") && !elements.contains("value.record.type")) {
        throw new ValidationException(
            String.format(
                "For a subject name strategy %s record.type is required!",
                topic.getSubjectNameStrategy()));

CollapsibleIfStatements

Since: PMD 3.1

Priority: Medium

Categories: Style

Remediation Points: 50000

Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator.

Example:

void bar() {
 if (x) { // original implementation
 if (y) {
 // do stuff
 }
 }
}

void bar() {
 if (x && y) { // optimized implementation
 // do stuff
 }
}

These nested if statements could be combined
Open

      if (!producerByteRate.equals(quota.getProducer_byte_rate().get())) {
        return true;
      }

CollapsibleIfStatements

Since: PMD 3.1

Priority: Medium

Categories: Style

Remediation Points: 50000

Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator.

Example:

void bar() {
 if (x) { // original implementation
 if (y) {
 // do stuff
 }
 }
}

void bar() {
 if (x && y) { // optimized implementation
 // do stuff
 }
}
Severity
Category
Status
Source
Language