linkedin/kafka-tools

View on GitHub

Showing 157 of 157 total issues

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

    help_string = ("Request:     {0}V{1}\n".format(cmd, api_version) +
                   "Format:      {0}V{1} group_id group_generation_id member_id retention_time ".format(cmd, api_version) +
                   "(topic (partition,offset[,metadata] ...) ...)\n" +
Severity: Major
Found in kafka/tools/protocol/requests/offset_commit_v2.py and 4 other locations - About 55 mins to fix
kafka/tools/protocol/requests/join_group_v0.py on lines 44..46
kafka/tools/protocol/requests/join_group_v1.py on lines 29..31
kafka/tools/protocol/requests/offset_commit_v1.py on lines 58..60
kafka/tools/protocol/requests/topic_metadata_v4.py on lines 27..29

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

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 5 locations. Consider refactoring.
Open

    help_string = ("Request:     {0}V{1}\n".format(cmd, api_version) +
                   "Format:      {0}V{1} group_id group_generation_id member_id ".format(cmd, api_version) +
                   "(topic (partition,offset,timestamp[,metadata] ...) ...)\n" +
Severity: Major
Found in kafka/tools/protocol/requests/offset_commit_v1.py and 4 other locations - About 55 mins to fix
kafka/tools/protocol/requests/join_group_v0.py on lines 44..46
kafka/tools/protocol/requests/join_group_v1.py on lines 29..31
kafka/tools/protocol/requests/offset_commit_v2.py on lines 28..30
kafka/tools/protocol/requests/topic_metadata_v4.py on lines 27..29

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

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 5 locations. Consider refactoring.
Open

    help_string = ("Request:     {0}V{1}\n".format(cmd, api_version) +
                   "Format:      {0}V{1} group_id session_timeout rebalance_timeout member_id protocol_type ".format(cmd, api_version) +
                   "(group_protocol_name,group_protocol_metadata ...)\n" +
Severity: Major
Found in kafka/tools/protocol/requests/join_group_v1.py and 4 other locations - About 55 mins to fix
kafka/tools/protocol/requests/join_group_v0.py on lines 44..46
kafka/tools/protocol/requests/offset_commit_v1.py on lines 58..60
kafka/tools/protocol/requests/offset_commit_v2.py on lines 28..30
kafka/tools/protocol/requests/topic_metadata_v4.py on lines 27..29

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

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 (len(partition) < 2) or (len(partition) > 3):
        raise ArgumentError("Partition tuple must have 3 or 4 fields")
Severity: Minor
Found in kafka/tools/protocol/requests/offset_commit_v0.py and 1 other location - About 50 mins to fix
kafka/tools/protocol/requests/offset_commit_v1.py on lines 24..25

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

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 (len(partition) < 3) or (len(partition) > 4):
        raise ArgumentError("Partition tuple must have 3 or 4 fields")
Severity: Minor
Found in kafka/tools/protocol/requests/offset_commit_v1.py and 1 other location - About 50 mins to fix
kafka/tools/protocol/requests/offset_commit_v0.py on lines 23..24

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

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

Avoid deeply nested control flow statements.
Open

                        if pmap[pos][partition.replicas[pos].id] <= target:
                            continue

                        # Find a new replica for the partition at this position
                        for bid in pmap[pos]:
Severity: Major
Found in kafka/tools/assigner/actions/balancemodules/even.py - About 45 mins to fix

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

    Severity: Minor
    Found in kafka/tools/protocol/responses/sasl_authenticate_v0.py and 1 other location - About 45 mins to fix
    kafka/tools/protocol/responses/sync_group_v1.py on lines 0..25

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

    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

    def error_short(err_num):
        if err_num in errors:
            return errors[err_num]['short']
        else:
            return "NOSUCHERROR"
    Severity: Minor
    Found in kafka/tools/protocol/errors.py and 1 other location - About 45 mins to fix
    kafka/tools/protocol/errors.py on lines 165..169

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

    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

    Avoid deeply nested control flow statements.
    Open

                            if pos not in source.partitions:
                                continue
    
    
    Severity: Major
    Found in kafka/tools/assigner/actions/balancemodules/count.py - About 45 mins to fix

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

      Severity: Minor
      Found in kafka/tools/protocol/responses/sync_group_v1.py and 1 other location - About 45 mins to fix
      kafka/tools/protocol/responses/sasl_authenticate_v0.py on lines 0..25

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

      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

      Avoid deeply nested control flow statements.
      Open

                              if diff == 0:
                                  break
                              if (pos in target.partitions) and (target.num_partitions_at_position(pos) > (max_count[pos][0] + 1)):
      Severity: Major
      Found in kafka/tools/assigner/actions/balancemodules/count.py - About 45 mins to fix

        Function execute has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def execute(self, num, total, zookeeper, tools_path, plugins=[], dry_run=True):
        Severity: Minor
        Found in kafka/tools/assigner/models/reassignment.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if (pos in target.partitions) and (target.num_partitions_at_position(pos) > (max_count[pos][0] + 1)):
                                      continue
          
          
          Severity: Major
          Found in kafka/tools/assigner/actions/balancemodules/count.py - About 45 mins to fix

            Function _send_some_brokers has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def _send_some_brokers(self, requests, ignore_errors=True):
                    """
                    Sends a request to one or more brokers. The responses are returned mapped to the broker that
                    they were retrieved from. This method uses a thread pool to parallelize sends.
            
            
            Severity: Minor
            Found in kafka/tools/client.py - 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

            Avoid deeply nested control flow statements.
            Open

                                    for partition in iterlist:
                                        # If we have moved enough partitions from this broker, exit out of the inner loop
                                        if (source.num_partitions_at_position(pos) < max_count[pos][0]) or (diff == 0):
                                            break
            
            
            Severity: Major
            Found in kafka/tools/assigner/actions/balancemodules/count.py - About 45 mins to fix

              Function execute has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def execute(self, num, total, zookeeper, tools_path, plugins=[], dry_run=True):
              Severity: Minor
              Found in kafka/tools/assigner/models/replica_election.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if diff == 0:
                                            break
                                        if pos not in source.partitions:
                Severity: Major
                Found in kafka/tools/assigner/actions/balancemodules/count.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          for bid in pmap[pos]:
                                              if pmap[pos][bid] >= target:
                                                  continue
                                              broker = self.cluster.brokers[bid]
                                              source = partition.replicas[pos]
                  Severity: Major
                  Found in kafka/tools/assigner/actions/balancemodules/even.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            for partition in iterlist:
                                                # If we have moved enough partitions to this broker, exit out of the inner loop
                                                if ((pos in target.partitions) and (target.num_partitions_at_position(pos) >= max_count[pos][0])) or (diff == 0):
                                                    break
                                                # Skip partitions that are already on the target broker or are being excluded
                    Severity: Major
                    Found in kafka/tools/assigner/actions/balancemodules/count.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if ((sizes[other_pos][broker_id] - partition_size < targets[other_pos] - margins[other_pos]) or
                                                 (sizes[other_pos][source.id] + partition_size > targets[pos] + margins[pos]) or
                                                 (sizes[pos][broker_id] + partition_size > targets[pos] + margins[pos]) or
                                                 (sizes[pos][source.id] - partition_size < targets[pos] - margins[pos])):
                                                  continue
                      Severity: Major
                      Found in kafka/tools/assigner/actions/balancemodules/size.py - About 45 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language