purbon/kafka-topology-builder

View on GitHub

Showing 167 of 167 total issues

AclsBindingsBuilder has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

public class AclsBindingsBuilder implements BindingsBuilderProvider {

  private static final Logger LOGGER = LogManager.getLogger(AclsBindingsBuilder.class);
  private static final String KAFKA_CLUSTER_NAME = "kafka-cluster";

    File JulieHttpClient.java has 265 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    package com.purbon.kafka.topology.clients;
    
    import static java.net.http.HttpRequest.BodyPublishers.noBody;
    import static java.net.http.HttpRequest.BodyPublishers.ofString;
    
    
    Severity: Minor
    Found in src/main/java/com/purbon/kafka/topology/clients/JulieHttpClient.java - About 2 hrs to fix

      File MDSApiClient.java has 263 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      package com.purbon.kafka.topology.api.mds;
      
      import static com.purbon.kafka.topology.api.mds.RequestScope.RESOURCE_NAME;
      import static com.purbon.kafka.topology.api.mds.RequestScope.RESOURCE_PATTERN_TYPE;
      import static com.purbon.kafka.topology.api.mds.RequestScope.RESOURCE_TYPE;
      Severity: Minor
      Found in src/main/java/com/purbon/kafka/topology/api/mds/MDSApiClient.java - About 2 hrs to fix

        Method deserialize has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

          @Override
          public Topology deserialize(JsonParser parser, DeserializationContext context)
              throws IOException {
        
            JsonNode rootNode = parser.getCodec().readTree(parser);

        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 deserialize has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          @Override
          public Topology deserialize(JsonParser parser, DeserializationContext context)
              throws IOException {
        
            JsonNode rootNode = parser.getCodec().readTree(parser);

          TopologyBuilderAdminClient has 21 methods (exceeds 20 allowed). Consider refactoring.
          Open

          public class TopologyBuilderAdminClient {
          
            private static final Logger LOGGER = LogManager.getLogger(TopologyBuilderAdminClient.class);
          
            private final AdminClient adminClient;

            Method updatePlan has 54 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              @Override
              public void updatePlan(ExecutionPlan plan, Map<String, Topology> topologies) throws IOException {
                Collection<? extends Artefact> currentArtefacts = loadActualClusterStateIfAvailable(plan);
            
                Set<Artefact> artefacts = new HashSet<>();
            Severity: Major
            Found in src/main/java/com/purbon/kafka/topology/ArtefactManager.java - About 2 hrs to fix

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

                private boolean validateReplicationFactor(short topicValue) throws ValidationException {
                  boolean result;
                  switch (replicationFactorOp) {
                    case "gt":
                      result = topicValue > replicationFactorValue;
              src/main/java/com/purbon/kafka/topology/validation/topic/PartitionNumberValidation.java on lines 42..67

              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 138.

              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

                private boolean validatePartitionCount(int topicValue) throws ValidationException {
                  boolean result;
                  switch (partitionNumberOp) {
                    case "gt":
                      result = topicValue > partitionNumberValue;
              src/main/java/com/purbon/kafka/topology/validation/topic/ReplicationFactorValidation.java on lines 44..69

              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 138.

              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 build has 53 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                public static JulieOps build(
                    String topologyFileOrDir,
                    String plansFile,
                    Configuration config,
                    TopologyBuilderAdminClient adminClient,
              Severity: Major
              Found in src/main/java/com/purbon/kafka/topology/JulieOps.java - About 2 hrs to fix

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

                package com.purbon.kafka.topology.actions.access;
                
                import com.purbon.kafka.topology.AccessControlProvider;
                import com.purbon.kafka.topology.actions.BaseAccessControlAction;
                import com.purbon.kafka.topology.roles.TopologyAclBinding;
                src/main/java/com/purbon/kafka/topology/actions/access/CreateBindings.java on lines 1..50

                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 136.

                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

                package com.purbon.kafka.topology.actions.access;
                
                import com.purbon.kafka.topology.AccessControlProvider;
                import com.purbon.kafka.topology.actions.BaseAccessControlAction;
                import com.purbon.kafka.topology.roles.TopologyAclBinding;
                src/main/java/com/purbon/kafka/topology/actions/access/ClearBindings.java on lines 1..51

                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 136.

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

                  private Optional<PlatformSystem> doKafkaConnectElements(JsonParser parser, JsonNode node)
                      throws IOException {
                
                    JsonNode acNode = node;
                    if (node.has(ACCESS_CONTROL)) {

                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

                File TopologyBuilderAdminClient.java has 252 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                package com.purbon.kafka.topology.api.adminclient;
                
                import com.purbon.kafka.topology.actions.topics.TopicConfigUpdatePlan;
                import com.purbon.kafka.topology.model.Topic;
                import com.purbon.kafka.topology.model.User;

                  Method buildProjectAclBindings has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    private List<AclBindingsResult> buildProjectAclBindings(Topology topology) {
                      List<AclBindingsResult> aclBindingsResults = new ArrayList<>();
                  
                      for (Project project : topology.getProjects()) {
                        if (config.shouldOptimizeAcls()) {
                  Severity: Minor
                  Found in src/main/java/com/purbon/kafka/topology/AccessControlManager.java - About 2 hrs to fix

                    Method getClustersState has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      @Override
                      protected Collection<? extends Artefact> getClustersState() throws IOException {
                        List<Either> list =
                            clients.values().stream()
                                .map(
                    Severity: Minor
                    Found in src/main/java/com/purbon/kafka/topology/KSqlArtefactManager.java - About 1 hr to fix

                      Method buildBindingsForConnect has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        @Override
                        public List<TopologyAclBinding> buildBindingsForConnect(Connector connector, String topicPrefix) {
                      
                          String principal = connector.getPrincipal();
                          List<String> readTopics = connector.getTopics().get("read");

                        Method updatePlan has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          @Override
                          public void updatePlan(ExecutionPlan plan, Map<String, Topology> topologies) throws IOException {
                            // Get current quotas
                            try {
                              Map<ClientQuotaEntity, Map<String, Double>> currentQuotas =
                        Severity: Minor
                        Found in src/main/java/com/purbon/kafka/topology/quotas/QuotasManager.java - About 1 hr to fix

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

                            private static String getPartitionNumberOp(Configuration config) throws ConfigurationException {
                              List<String> validOpCodes = Arrays.asList("gt", "lt", "eq", "gte", "lte", "ne");
                              try {
                                String opCode =
                                    config.getProperty(TOPOLOGY_VALIDATIONS_PARTITION_NUMBER_OP).toLowerCase().strip();
                          src/main/java/com/purbon/kafka/topology/validation/topic/ReplicationFactorValidation.java on lines 71..89

                          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 106.

                          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 getClustersState has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            @Override
                            protected Collection<? extends Artefact> getClustersState() throws IOException {
                              List<Either> list =
                                  clients.values().stream()
                                      .map(
                            Severity
                            Category
                            Status
                            Source
                            Language