devshawn/kafka-gitops

View on GitHub

Showing 22 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;
Severity: Minor
Found in src/main/java/com/devshawn/kafka/gitops/StateManager.java - About 3 hrs to fix

    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);
    
    
    Severity: Major
    Found in src/main/java/com/devshawn/kafka/gitops/manager/PlanManager.java - About 2 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                  case ADD:
                      System.out.println(green(String.format("+ [ACL] %s", aclPlan.getName())));
                      System.out.println(green(String.format("\t + resource_name: %s", aclDetails.getName())));
                      System.out.println(green(String.format("\t + resource_type: %s", aclDetails.getType())));
                      System.out.println(green(String.format("\t + resource_pattern: %s", aclDetails.getPattern())));
      Severity: Major
      Found in src/main/java/com/devshawn/kafka/gitops/util/LogUtil.java and 1 other location - About 2 hrs to fix
      src/main/java/com/devshawn/kafka/gitops/util/LogUtil.java on lines 134..144

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 176.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                  case REMOVE:
                      System.out.println(red(String.format("- [ACL] %s", aclPlan.getName())));
                      System.out.println(red(String.format("\t - resource_name: %s", aclDetails.getName())));
                      System.out.println(red(String.format("\t - resource_type: %s", aclDetails.getType())));
                      System.out.println(red(String.format("\t - resource_pattern: %s", aclDetails.getPattern())));
      Severity: Major
      Found in src/main/java/com/devshawn/kafka/gitops/util/LogUtil.java and 1 other location - About 2 hrs to fix
      src/main/java/com/devshawn/kafka/gitops/util/LogUtil.java on lines 123..133

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 176.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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());
      Severity: Minor
      Found in src/main/java/com/devshawn/kafka/gitops/manager/PlanManager.java - About 1 hr to fix

        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 -> {
        Severity: Minor
        Found in src/main/java/com/devshawn/kafka/gitops/service/KafkaService.java - About 1 hr to fix

          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()
          Severity: Minor
          Found in src/main/java/com/devshawn/kafka/gitops/manager/PlanManager.java - About 1 hr to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    switch (topicDetailsPlan.getPartitionsAction()) {
                        case ADD:
                            System.out.println(green(String.format("\t+ partitions: %s", topicDetailsPlan.getPartitions().get())));
                            break;
                        case UPDATE:
            Severity: Major
            Found in src/main/java/com/devshawn/kafka/gitops/util/LogUtil.java and 1 other location - About 1 hr to fix
            src/main/java/com/devshawn/kafka/gitops/util/LogUtil.java on lines 88..100

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 102.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    switch (topicDetailsPlan.getReplicationAction()) {
                      case ADD:
                          System.out.println(green(String.format("\t+ replication: %s", topicDetailsPlan.getReplication().get())));
                          break;
                      case UPDATE:
            Severity: Major
            Found in src/main/java/com/devshawn/kafka/gitops/util/LogUtil.java and 1 other location - About 1 hr to fix
            src/main/java/com/devshawn/kafka/gitops/util/LogUtil.java on lines 75..87

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 102.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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);
            Severity: Minor
            Found in src/main/java/com/devshawn/kafka/gitops/service/ParserService.java - About 1 hr to fix

              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;
              Severity: Minor
              Found in src/main/java/com/devshawn/kafka/gitops/util/LogUtil.java - About 1 hr to fix

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                            if (desiredStateFile.getCustomServiceAcls().containsKey(name)) {
                                Map<String, CustomAclDetails> customAcls = desiredStateFile.getCustomServiceAcls().get(name);
                                customAcls.forEach((aclName, customAcl) -> {
                                    AclDetails.Builder aclDetails = AclDetails.fromCustomAclDetails(customAcl);
                                    aclDetails.setPrincipal(String.format("User:%s", serviceAccountId));
                Severity: Major
                Found in src/main/java/com/devshawn/kafka/gitops/StateManager.java and 1 other location - About 1 hr to fix
                src/main/java/com/devshawn/kafka/gitops/StateManager.java on lines 212..219

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 92.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                            if (desiredStateFile.getCustomUserAcls().containsKey(name)) {
                                Map<String, CustomAclDetails> customAcls = desiredStateFile.getCustomUserAcls().get(name);
                                customAcls.forEach((aclName, customAcl) -> {
                                    AclDetails.Builder aclDetails = AclDetails.fromCustomAclDetails(customAcl);
                                    aclDetails.setPrincipal(String.format("User:%s", serviceAccountId));
                Severity: Major
                Found in src/main/java/com/devshawn/kafka/gitops/StateManager.java and 1 other location - About 1 hr to fix
                src/main/java/com/devshawn/kafka/gitops/StateManager.java on lines 187..194

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 92.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                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();
                  Severity: Minor
                  Found in src/main/java/com/devshawn/kafka/gitops/service/ParserService.java - About 55 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

                  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")) {

                  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);
                  Severity: Minor
                  Found in src/main/java/com/devshawn/kafka/gitops/service/ParserService.java - About 45 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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                          desiredStateFile.getCustomUserAcls().forEach((service, details) -> {
                              try {
                                  details.values().forEach(CustomAclDetails::validate);
                              } catch (InvalidAclDefinitionException ex) {
                                  String message = String.format("Custom ACL definition for user '%s' is invalid for field '%s'. Allowed values: [%s]", service, ex.getField(), String.join(", ", ex.getAllowedValues()));
                  Severity: Minor
                  Found in src/main/java/com/devshawn/kafka/gitops/StateManager.java and 1 other location - About 35 mins to fix
                  src/main/java/com/devshawn/kafka/gitops/StateManager.java on lines 292..299

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 66.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                          desiredStateFile.getCustomServiceAcls().forEach((service, details) -> {
                              try {
                                  details.values().forEach(CustomAclDetails::validate);
                              } catch (InvalidAclDefinitionException ex) {
                                  String message = String.format("Custom ACL definition for service '%s' is invalid for field '%s'. Allowed values: [%s]", service, ex.getField(), String.join(", ", ex.getAllowedValues()));
                  Severity: Minor
                  Found in src/main/java/com/devshawn/kafka/gitops/StateManager.java and 1 other location - About 35 mins to fix
                  src/main/java/com/devshawn/kafka/gitops/StateManager.java on lines 301..308

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 66.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                          if (topicDetailsPlan.get().getPartitionsAction() != null && ! topicDetailsPlan.get().getPartitionsAction().equals(PlanAction.NO_CHANGE)) {
                            builder.setPartitions(topicDetailsPlan.get().getPartitions());
                              builder.setPreviousPartitions(topicDetailsPlan.get().getPreviousPartitions());
                              nochanges = false;
                          }
                  src/main/java/com/devshawn/kafka/gitops/domain/plan/TopicDetailsPlan.java on lines 27..31

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 62.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Severity
                  Category
                  Status
                  Source
                  Language