IRC-SPHERE/HyperStream

View on GitHub

Showing 2,622 of 2,627 total issues

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

    def _execute(self, sources, interval):
        if self.categorical:
            for t, d in sources[0].window(interval, force_calculation=True):
                yield StreamInstance(t, dict(map(safe_key, Counter(d).items())))
        else:
Severity: Minor
Found in hyperstream/tools/percentiles_to_csv/2017-07-18_v0.0.1.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 get_stream_writer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def get_stream_writer(self, stream):
        def writer(document_collection):
            if stream.stream_id not in self:
                raise RuntimeError("Data slot does not exist for {}, perhaps create_stream was not used?"
                                   .format(stream))
Severity: Minor
Found in hyperstream/channels/assets_file_channel.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 _execute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def _execute(self, sources, alignment_stream, interval):
        if self.categorical:
            for t, d in sources[0].window(interval, force_calculation=True):
                yield StreamInstance(t, dict(map(safe_key, Counter(d).items())))
        else:
Severity: Minor
Found in hyperstream/tools/histogram_from_list/2017-07-03_v0.0.1.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 __init__ has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, name, meta_data=None):
        self.name = name
        if meta_data:
            # if isinstance(meta_data, dict):
            #     keys = sorted(meta_data.keys())
Severity: Minor
Found in hyperstream/stream/stream_id.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

    def __init__(self, start, stop=None, step=1, seed=None):
        super(Randrange, self).__init__(start=start, stop=stop, step=step, seed=seed)
        random.seed(self.seed)
Severity: Minor
Found in plugins/data_generators/tools/randrange/2017-06-20_v1.0.0.py and 1 other location - About 55 mins to fix
plugins/data_generators/tools/triangular/2017-06-20_v1.0.0.py on lines 36..38

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

    def __init__(self, low=0.0, high=1.0, mode=None, seed=None):
        super(Triangular, self).__init__(low=low, high=high, mode=mode, seed=seed)
        random.seed(self.seed)
Severity: Minor
Found in plugins/data_generators/tools/triangular/2017-06-20_v1.0.0.py and 1 other location - About 55 mins to fix
plugins/data_generators/tools/randrange/2017-06-20_v1.0.0.py on lines 33..35

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

Function create_workflow has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def create_workflow(self, workflow_id, name, owner, description, online=False, monitor=False, safe=True):
Severity: Major
Found in hyperstream/hyperstream.py - About 50 mins to fix

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

    def __init__(self, channel, stream_id, calculated_intervals, last_accessed, last_updated, sandbox,
Severity: Major
Found in hyperstream/stream/stream.py - About 50 mins to fix

Avoid deeply nested control flow statements.
Open

                        if p not in set(sink.plate_ids):
                            raise IncompatiblePlatesError("{} not in sink plates".format(p))
            plates = sink.plates
Severity: Major
Found in hyperstream/workflow/workflow.py - About 45 mins to fix

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

    def now_minus(cls, weeks=0, days=0, hours=0, minutes=0, seconds=0, milliseconds=0):
Severity: Minor
Found in hyperstream/time_interval.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if p not in set(source_plates):
                            raise IncompatiblePlatesError("{} not in source plates".format(p))
                    for p in source_plates:
Severity: Major
Found in hyperstream/workflow/workflow.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                            if value[k] != old[k]:
                                raise KeyError(
                                    "Key {} has already been set with value {}, new value {}"
                                    .format(key, self[key], value))
                        except ValueError:
Severity: Major
Found in hyperstream/utils/containers.py - About 45 mins to fix

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

    def get_tool(self, name, parameters, version=None):
        """
        Gets the tool object from the tool channel(s), and instantiates it using the tool parameters

        :param name: The name or stream id for the tool in the tool channel
Severity: Minor
Found in hyperstream/channels/channel_manager.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

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

    def find_streams(self, **kwargs):
        """
        Finds streams with the given meta data values. Useful for debugging purposes.

        :param kwargs: The meta data as keyword arguments
Severity: Minor
Found in hyperstream/channels/base_channel.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

                        if self.header:
                            values = dict(zip(colnames, map(my_float, elements)))
                        else:
                            values = map(float, elements)
                        instance = StreamInstance(dt, values)
Severity: Major
Found in plugins/data_importers/tools/csv_multi_reader/2017-07-21_v0.0.1.py - About 45 mins to fix

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

    def check_plate_compatibility(tool, source_plate, sink_plate):
        """
        Checks whether the source and sink plate are compatible given the tool

        :param tool: The tool
Severity: Minor
Found in hyperstream/workflow/workflow.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

                        if next(p.is_root for p in sources[-1].plates):
                            if len(sink.plates) != 1:
                                raise IncompatiblePlatesError(
                                    "Multiple sink plates defined. "
                                    "Did you intend a simplification of 2 source plates to a sink plate?")
Severity: Major
Found in hyperstream/workflow/workflow.py - About 45 mins to fix

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

    def _execute(self, sources, alignment_stream, interval):
        # Combine the data, apply the mapping and sort (inefficient!)
        results = dict()
        for source in sources:
            data = source.window(interval, force_calculation=True)
Severity: Minor
Found in hyperstream/tools/aggregate_into_dict_and_apply/2017-05-26_v0.0.1.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

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

    def __init__(self, workflow_id, name, description, owner, online=False, monitor=False):
Severity: Minor
Found in hyperstream/workflow/workflow.py - About 45 mins to fix

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

    def _execute(self, sources, interval):
        time_interval = TimeInterval(MIN_DATE, interval.end)
        selector_meta_data = sources[0].window(time_interval, force_calculation=True).last().value

        found_source = False
Severity: Minor
Found in hyperstream/tools/index_of_by_stream/2016-10-26_v0.1.0.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

Severity
Category
Status
Source
Language