IRC-SPHERE/HyperStream

View on GitHub

Showing 171 of 2,627 total issues

File containers.py has 272 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# The MIT License (MIT) # Copyright (c) 2014-2017 University of Bristol
#
#  Permission is hereby granted, free of charge, to any person obtaining a copy
#  of this software and associated documentation files (the "Software"), to deal
#  in the Software without restriction, including without limitation the rights
Severity: Minor
Found in hyperstream/utils/containers.py - About 2 hrs to fix

Function _execute has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def _execute(self, sources, alignment_stream, interval):

        # Put all of the data in a dict of sorted lists (inefficient!)
        data = dict((source.stream_id,
                     sorted(source.window(interval, force_calculation=True), key=lambda x: x.timestamp))
Severity: Minor
Found in hyperstream/tools/aggregate/2016-10-26_v0.1.0.py - About 2 hrs 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 _execute has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def _execute(self, source, interval):
        source_last_doc = source.window(interval, force_calculation=True).last()
        if not source_last_doc:
            return
        timestamp, data = source_last_doc
Severity: Minor
Found in hyperstream/tools/asset_plate_generator/2017-03-17_v0.2.0.py - About 2 hrs 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

TimeInterval has 21 functions (exceeds 20 allowed). Consider refactoring.
Open

class TimeInterval(namedtuple("TimeInterval", "start end")):
    """
    Time interval object.
    Thin wrapper around a (start, end) tuple of datetime objects that provides some validation
    """
Severity: Minor
Found in hyperstream/time_interval.py - About 2 hrs to fix

Function _execute has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def _execute(self, sources, alignment_stream, interval):
        if self.names and len(self.names) != len(sources):
            raise TypeError("Tool AlignedMerge expected {} streams as input, got {} instead".format(
                len(self.names), len(sources)))
        streams = [list(source.window(interval, force_calculation=True)) for source in sources]
Severity: Minor
Found in hyperstream/tools/aligned_merge/2017-06-21_v0.1.2.py - About 2 hrs 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 _execute has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def _execute(self, sources, alignment_stream, interval):
        if self.names and len(self.names) != len(sources):
            raise TypeError("Tool AlignedMerge expected {} streams as input, got {} instead".format(
                len(self.names), len(sources)))
        streams = [list(source.window(interval, force_calculation=True)) for source in sources]
Severity: Minor
Found in hyperstream/tools/aligned_merge/2016-11-25_v0.1.1.py - About 2 hrs 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 parse_time_tuple has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def parse_time_tuple(start, end):
    """
    Parse a time tuple. These can be:
      relative in seconds,       e.g. (-4, 0)
      relative in timedelta,     e.g. (timedelta(seconds=-4), timedelta(0))
Severity: Minor
Found in hyperstream/time_interval.py - About 2 hrs 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 get_splitting_stream has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def get_splitting_stream(self, input_plate_value):
        """
        Get the splitting stream

        :param input_plate_value: The input plate value
Severity: Minor
Found in hyperstream/factor/factor.py - About 2 hrs 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 get_tool_class has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def get_tool_class(self, tool):
        """
        Gets the actual class which can then be instantiated with its parameters

        :param tool: The tool name or id
Severity: Minor
Found in hyperstream/channels/channel_manager.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 a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, tool, source_nodes, sink_node, alignment_node, plates):
        """
        Initialise this factor

        :param tool: The tool
Severity: Minor
Found in hyperstream/factor/factor.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 get_stream_writer has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def get_stream_writer(self, stream):
        """
        Gets the database channel writer
        The mongoengine model checks whether a stream_id/datetime pair already exists in the DB (unique pairs)
        Should be overridden by users' personal channels - allows for non-mongo outputs.
Severity: Minor
Found in hyperstream/channels/database_channel.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 connect has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def connect(self, server_config):
        """Connect using the configuration given

        :param server_config: The server configuration
        """
Severity: Minor
Found in hyperstream/client.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 __iter__ has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def __iter__(self):
        required_intervals = TimeIntervals([self.time_interval]) - self.stream.calculated_intervals
        from . import AssetStream
        # if not isinstance(self.stream, AssetStream) and not required_intervals.is_empty:
        if not required_intervals.is_empty:
Severity: Minor
Found in hyperstream/stream/stream_view.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

Consider simplifying this complex logical expression.
Open

                        if base == Tool:
                            def tool_factory_function(sources, alignment_node=None, **parameters):
                                """
                                Factory function for creating factors inside a workflow

Severity: Critical
Found in hyperstream/hyperstream.py - About 1 hr to fix

Function _execute has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def _execute(self, source, interval):
        source_last_doc = source.window(interval, force_calculation=True).last()
        if not source_last_doc:
            return
        timestamp, data = source_last_doc
Severity: Minor
Found in hyperstream/tools/asset_plate_generator/2016-12-12_v0.1.2.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 _execute has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def _execute(self, sources, alignment_stream, interval):
        if self.names and len(self.names) != len(sources):
            raise TypeError("Tool AlignedMerge expected {} streams as input, got {} instead".format(
                len(self.names), len(sources)))
        streams = [iter(source.window(interval, force_calculation=True)) for source in sources]
Severity: Minor
Found in hyperstream/tools/aligned_merge/2016-10-26_v0.0.1.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 percentile has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def percentile(a, q):
    """
    Compute the qth percentile of the data along the specified axis.
    Simpler version than the numpy version that always flattens input arrays.

Severity: Minor
Found in hyperstream/utils/statistics/percentile.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 _execute has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def _execute(self, sources, alignment_stream, interval):

        if self.dateparser is None:
            self.dateparser = parse
        # Let's make the assumption that the first field is the timestamp
Severity: Minor
Found in examples/plugins/example/tools/csv_reader/2017-06-20_v0.0.2.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 _execute has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def _execute(self, sources, alignment_stream, interval):
        for time, data in sources[0].window(interval, force_calculation=True):
            dict_mean = dict()
            if len(data)==0:
                yield StreamInstance(time, dict_mean)
Severity: Minor
Found in hyperstream/tools/list_dict_mean/2016-12-15_v0.0.1.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 _execute has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def _execute(self, source, splitting_stream, interval, meta_data_id, output_plate_values):
        if splitting_stream is not None:
            raise NotImplementedError("Splitting stream not supported for this tool")

        for timestamp, value in source.window(interval, force_calculation=True):
Severity: Minor
Found in hyperstream/tools/splitter_with_unlist/2016-10-24_v0.0.1.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

Severity
Category
Status
Source
Language