rohanpm/more-executors

View on GitHub

Showing 159 of 159 total issues

File retry.py has 386 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from concurrent.futures import Executor
from threading import RLock, Thread
import logging
import weakref

Severity: Minor
Found in more_executors/_impl/retry.py - About 5 hrs to fix

    ProxyFuture has 36 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ProxyFuture(MapFuture):
        # A future which proxies many calls through to the underlying object.
        def __init__(self, delegate, timeout):
            self.__timeout = timeout
            super(ProxyFuture, self).__init__(delegate)
    Severity: Minor
    Found in more_executors/_impl/futures/proxy.py - About 4 hrs to fix

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

      @ensure_futures
      def f_or(f, *fs):
          """Boolean ``OR`` over a number of futures.
      
          Signature: :code:`Future<A>[, Future<B>[, ...]] ⟶ Future<A|B|...>`
      Severity: Major
      Found in more_executors/_impl/futures/bool.py and 1 other location - About 2 hrs to fix
      more_executors/_impl/futures/bool.py on lines 138..170

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

      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

      @ensure_futures
      def f_and(f, *fs):
          """Boolean ``AND`` over a number of futures.
      
          Signature: :code:`Future<A>[, Future<B>[, ...]] ⟶ Future<A|B|...>`
      Severity: Major
      Found in more_executors/_impl/futures/bool.py and 1 other location - About 2 hrs to fix
      more_executors/_impl/futures/bool.py on lines 78..110

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

      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

      Function _submit_loop has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def _submit_loop(executor_ref):
          # Runs in a separate thread continuously submitting to the delegate
          # executor until no jobs are ready, or waiting until next job is ready
          while True:
              executor = executor_ref()
      Severity: Minor
      Found in more_executors/_impl/retry.py - About 1 hr 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

      Function __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(
      Severity: Major
      Found in more_executors/_impl/retry.py - About 1 hr to fix

        Function _get_next_job has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def _get_next_job(self):
                # Find and return the next job to be handled, if any.
                # This means a job with when < now, or with stop_retry == True,
                # or if there's none, then the job with the minimum value of when.
                min_job = None
        Severity: Minor
        Found in more_executors/_impl/retry.py - About 1 hr 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

        Function _poll_loop has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        def _poll_loop(executor_ref):
            while True:
                executor = executor_ref()
                if not executor:
                    break
        Severity: Minor
        Found in more_executors/_impl/poll.py - 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

        Function _submit_loop_iter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        def _submit_loop_iter(executor):
            if not executor:
                return
        
            if executor._shutdown.is_shutdown or is_shutdown():
        Severity: Minor
        Found in more_executors/_impl/throttle.py - 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

        Function handle_done has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def handle_done(self, index, f):
                set_result = False
                set_exception = False
                cancel = False
        
        
        Severity: Minor
        Found in more_executors/_impl/futures/zip.py - 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

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

        @ensure_future
        def f_map(future, fn=None, error_fn=None):
            """Map the output value of a future using the given functions.
        
            Signature: :code:`Future<A>, fn<A⟶B> ⟶ Future<B>`
        Severity: Minor
        Found in more_executors/_impl/futures/map.py and 1 other location - About 50 mins to fix
        more_executors/_impl/futures/map.py on lines 39..72

        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

        @ensure_future
        def f_flat_map(future, fn=None, error_fn=None):
            """Map the output value of a future using the given future-returning functions.
        
            Like :meth:`f_map`, except that the mapping functions must return a future,
        Severity: Minor
        Found in more_executors/_impl/futures/map.py and 1 other location - About 50 mins to fix
        more_executors/_impl/futures/map.py on lines 7..36

        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

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

        def record_done(f, started_when, time, inprogress, cancelled, failed):
        Severity: Minor
        Found in more_executors/_impl/metrics/__init__.py - About 45 mins to fix

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

              def __init__(
          Severity: Minor
          Found in more_executors/_impl/poll.py - About 45 mins to fix

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

                def _delegate_resolved(self, delegate):
                    assert delegate is self._delegate, "BUG: called with %s, expected %s" % (
                        delegate,
                        self._delegate,
                    )
            Severity: Minor
            Found in more_executors/_impl/map.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

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

                    for arg in to_check:
                        if not is_future(arg):
                            raise TypeError(
                                "%s() called with non-future value: %s" % (f.__name__, repr(arg))
            Severity: Minor
            Found in more_executors/_impl/futures/check.py and 1 other location - About 40 mins to fix
            more_executors/_impl/futures/check.py on lines 30..32

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

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

                def set_exception(self, exception):
                    with self._me_lock:
                        super(MapFuture, self).set_exception(exception)
                    self._me_invoke_callbacks()
            Severity: Major
            Found in more_executors/_impl/map.py and 2 other locations - About 40 mins to fix
            more_executors/_impl/map.py on lines 85..88
            more_executors/_impl/poll.py on lines 63..71

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

            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

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

                    if not is_future(arg):
                        raise TypeError(
                            "%s() called with non-future value: %s" % (f.__name__, repr(arg))
            Severity: Minor
            Found in more_executors/_impl/futures/check.py and 1 other location - About 40 mins to fix
            more_executors/_impl/futures/check.py on lines 10..13

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

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

                def set_result(self, result):
                    with self._me_lock:
                        super(MapFuture, self).set_result(result)
                    self._me_invoke_callbacks()
            Severity: Major
            Found in more_executors/_impl/map.py and 2 other locations - About 40 mins to fix
            more_executors/_impl/map.py on lines 90..93
            more_executors/_impl/poll.py on lines 63..71

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

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

                def set_exception(self, exception):
                    with self._me_lock:
                        # We can't get here because we always try set_exception_info first,
                        # which succeeds if done() is true, in which case we won't fall
                        # back to set_exception.
            Severity: Major
            Found in more_executors/_impl/poll.py and 2 other locations - About 40 mins to fix
            more_executors/_impl/map.py on lines 85..88
            more_executors/_impl/map.py on lines 90..93

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

            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