IBM/pytorchpipe

View on GitHub

Showing 102 of 320 total issues

Function export_to_string has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def export_to_string(self, additional_tag=''):
        """
        Method returns current statistics in the form of string using the
        possessed formatting.

Severity: Minor
Found in ptp/utils/statistics_collector.py - About 35 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 recursive_summarize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def recursive_summarize(self, module_, indent_, module_name_):
        """
        Function that recursively inspects the (sub)modules and records their statistics\
          (like names, types, parameters, their numbers etc.)

Severity: Minor
Found in ptp/components/models/model.py - About 35 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 load_dataset has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def load_dataset(self, source_files):
        """
        Loads the dataset from source files.

        :param source_files: list of jSON file with image ids, questions, answers, scene graphs, etc.
Severity: Minor
Found in ptp/components/tasks/image_text_to_class/gqa.py - About 35 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 export_to_tensorboard has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def export_to_tensorboard(self, tb_writer = None):
        """
        Method exports current statistical aggregators values to TensorBoard.

        :param tb_writer: TensorBoard writer, optional
Severity: Minor
Found in ptp/utils/statistics_aggregator.py - About 35 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 __call__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def __call__(self, data_streams):
        """
        Shows a sample from the batch.

        :param data_streams: :py:class:`ptp.utils.DataStreams` object.
Severity: Minor
Found in ptp/components/viewers/image_viewer.py - About 35 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 leafs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def leafs(self):
        """
        Yields the leafs of the current :py:class:`ConfigInterface`.

        """
Severity: Minor
Found in ptp/configuration/config_interface.py - About 35 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 export_output_definitions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def export_output_definitions(self, all_definitions, log_errors=True):
        """ 
        Exports output definitions to all_definitions, checking errors (e.g. if output field is already present in all_definitions).

        :param all_definitions: dictionary containing output data definitions (each of type :py:class:`ptp.configuration.DataDefinition`).
Severity: Minor
Found in ptp/components/component.py - About 35 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 too many return statements within this function.
Open

        return [obj for _ in target_gpus]
Severity: Major
Found in ptp/utils/data_streams_parallel.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                return list(map(type(obj), zip(*map(scatter_map, obj.items()))))    
    Severity: Major
    Found in ptp/utils/data_streams_parallel.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return type(out)(map(gather_map, zip(*outputs)))
      Severity: Major
      Found in ptp/utils/data_streams_parallel.py - About 30 mins to fix

        Function build has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def build(name, config):
                """
                Method creates a single component on the basis of configuration section.
                Raises ConfigurationError exception when encountered issues.
        
        
        Severity: Minor
        Found in ptp/application/component_factory.py - About 25 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 output_data_definitions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def output_data_definitions(self):
                """ 
                Function returns a dictionary with definitions of output data produced the component.
        
                :return: dictionary containing output data definitions (each of type :py:class:`ptp.utils.DataDefinition`).
        Severity: Minor
        Found in ptp/components/models/general_usage/recurrent_neural_network.py - About 25 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 export_to_csv has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def export_to_csv(self, csv_file=None):
                """
                This method writes the current statistical aggregators values to the `csv_file` using the associated formatting.
        
                :param csv_file: File stream opened for writing, optional.
        Severity: Minor
        Found in ptp/utils/statistics_aggregator.py - About 25 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 pad_trunc_list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def pad_trunc_list(l: list, length: int, padding_value = 0, eos_value = None):
            """
            Will apply padding / clipping to list to meet requested length.
            Works on the list in-place.
        
        
        Severity: Minor
        Found in ptp/components/mixins/word_mappings.py - About 25 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 export_to_checkpoint has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def export_to_checkpoint(self):
                """
                This method exports the collected data into a dictionary using the associated formatting.
        
                """
        Severity: Minor
        Found in ptp/utils/statistics_collector.py - About 25 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 load_dataset has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def load_dataset(self, source_files, source_image_folders, source_categories):
                """
                Loads the dataset from one or more files.
        
                :param source_files: List of source files.
        Severity: Minor
        Found in ptp/components/tasks/image_text_to_class/vqa_med_2019.py - About 25 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 input_data_definitions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def input_data_definitions(self):
                """ 
                Function returns a dictionary with definitions of input data that are required by the component.
        
                :return: dictionary containing input data definitions (each of type :py:class:`ptp.utils.DataDefinition`).
        Severity: Minor
        Found in ptp/components/models/general_usage/recurrent_neural_network.py - About 25 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 load_testset_without_answers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def load_testset_without_answers(self, data_file, image_folder):
                """
                Loads the test set without answers.
        
                :param data_file: Source file.
        Severity: Minor
        Found in ptp/components/tasks/image_text_to_class/vqa_med_2019.py - About 25 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 sentences_to_tensor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def sentences_to_tensor(self, data_streams):
                """
                Encodes "inputs" in the format of batch of list of words into a single tensor with corresponding indices.
        
                :param data_streams: :py:class:`ptp.datatypes.DataStreams` object containing (among others):
        Severity: Minor
        Found in ptp/components/language/sentence_indexer.py - About 25 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 to has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def to(self, device=None, keys_to_move=None, non_blocking=False):
                """
                Moves object(s) to device
        
                .. note::
        Severity: Minor
        Found in ptp/data_types/data_streams.py - About 25 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