KarrLab/obj_tables

View on GitHub
obj_tables/io.py

Summary

Maintainability
F
3 wks
Test Coverage
A
99%

File io.py has 2243 lines of code (exceeds 250 allowed). Consider refactoring.
Open

""" Reading/writing schema objects to/from files

* Comma separated values (.csv)
* XLSX (.xlsx)
* JavaScript Object Notation (.json)
Severity: Major
Found in obj_tables/io.py - About 6 days to fix

    Function run has a Cognitive Complexity of 147 (exceeds 5 allowed). Consider refactoring.
    Open

        def run(self, path, schema_name=None, models=None,
                allow_multiple_sheets_per_model=False,
                ignore_missing_models=False, ignore_extra_models=False,
                ignore_sheet_order=False,
                include_all_attributes=True, ignore_missing_attributes=False, ignore_extra_attributes=False,
    Severity: Minor
    Found in obj_tables/io.py - About 2 days 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 read_model has a Cognitive Complexity of 109 (exceeds 5 allowed). Consider refactoring.
    Open

        def read_model(self, reader, sheet_name, schema_name, model, include_all_attributes=True,
                       ignore_missing_attributes=False, ignore_extra_attributes=False,
                       ignore_attribute_order=False, ignore_empty_rows=True,
                       validate=True):
            """ Instantiate a list of objects from data in a table in a file
    Severity: Minor
    Found in obj_tables/io.py - About 2 days 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 write_model has a Cognitive Complexity of 94 (exceeds 5 allowed). Consider refactoring.
    Open

        def write_model(self, writer, model, objects, schema_name, date, doc_metadata, doc_metadata_model, model_metadata, sheet_models,
                        include_all_attributes=True, encoded=None, write_empty_models=True, write_empty_cols=True,
                        extra_entries=0, protected=True):
            """ Write a list of model objects to a file
    
    
    Severity: Minor
    Found in obj_tables/io.py - About 1 day 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 link_model has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
    Open

        def link_model(self, model, attributes, data, objects, objects_by_primary_attribute, decoded=None):
            """ Construct object graph
    
            Args:
                model (:obj:`Model`): an :obj:`obj_tables.core.Model`
    Severity: Minor
    Found in obj_tables/io.py - About 1 day 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 read_sheet has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

        def read_sheet(self, model, reader, sheet_name, num_row_heading_columns=0, num_column_heading_rows=0,
                       ignore_empty_rows=False, ignore_empty_cols=False):
            """ Read worksheet or file into a two-dimensional list
    
            Args:
    Severity: Minor
    Found in obj_tables/io.py - About 6 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 run has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

        def run(self, path, objects, schema_name=None, doc_metadata=None, model_metadata=None,
                models=None, get_related=True, include_all_attributes=True,
                validate=True, title=None, description=None, keywords=None, version=None, language=None, creator=None,
                write_toc=False, write_schema=False, write_empty_models=True, write_empty_cols=True,
                extra_entries=0, group_objects_by_model=True,
    Severity: Minor
    Found in obj_tables/io.py - About 5 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 run has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        def run(self, path, objects, schema_name=None, doc_metadata=None, model_metadata=None,
                models=None, get_related=True, include_all_attributes=True, validate=True,
                title=None, description=None, keywords=None, version=None, language=None, creator=None,
                write_toc=True, write_schema=False, write_empty_models=True, write_empty_cols=True,
                extra_entries=0, group_objects_by_model=True, data_repo_metadata=False, schema_package=None,
    Severity: Minor
    Found in obj_tables/io.py - About 5 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 run has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        def run(self, path, schema_name=None, models=None,
                allow_multiple_sheets_per_model=False,
                ignore_missing_models=False, ignore_extra_models=False,
                ignore_sheet_order=False,
                include_all_attributes=True, ignore_missing_attributes=False, ignore_extra_attributes=False,
    Severity: Minor
    Found in obj_tables/io.py - About 3 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 run has 24 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def run(self, path, objects, schema_name=None, doc_metadata=None, model_metadata=None, models=None,
    Severity: Major
    Found in obj_tables/io.py - About 3 hrs to fix

      Function run has 24 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def run(self, path, objects, schema_name=None, doc_metadata=None, model_metadata=None,
      Severity: Major
      Found in obj_tables/io.py - About 3 hrs to fix

        Function run has 24 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def run(self, path, objects, schema_name=None, doc_metadata=None, model_metadata=None,
        Severity: Major
        Found in obj_tables/io.py - About 3 hrs to fix

          Function run has 24 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def run(self, path, objects, schema_name=None, doc_metadata=None, model_metadata=None,
          Severity: Major
          Found in obj_tables/io.py - About 3 hrs to fix

            Function run has 24 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def run(self, path, objects, schema_name=None, doc_metadata=None, model_metadata=None,
            Severity: Major
            Found in obj_tables/io.py - About 3 hrs to fix

              Function read_worksheet_metadata has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                  def read_worksheet_metadata(cls, sheet_name, rows):
                      """ Read worksheet metadata
              
                      Args:
                          sheet_name (:obj:`str`): sheet name
              Severity: Minor
              Found in obj_tables/io.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 write_sheet has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                  def write_sheet(self, writer, model, data, headings, metadata_headings, validation,
                                  extra_entries=0, merge_ranges=None, protected=True):
                      """ Write data to sheet
              
                      Args:
              Severity: Minor
              Found in obj_tables/io.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 write_schema has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

                  def write_schema(self, writer, models, name, date, doc_metadata, protected=True):
                      """ Write a worksheet with a schema
              
                      Args:
                          writer (:obj:`wc_utils.workbook.io.Writer`): io writer
              Severity: Minor
              Found in obj_tables/io.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 run has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

                  def run(self, path, objects, schema_name=None, doc_metadata=None, model_metadata=None,
                          models=None, get_related=True, include_all_attributes=True, validate=True,
                          title=None, description=None, keywords=None, version=None, language=None, creator=None,
                          write_toc=True, write_schema=False, write_empty_models=True, write_empty_cols=True,
                          extra_entries=0, group_objects_by_model=True, data_repo_metadata=False, schema_package=None,
              Severity: Minor
              Found in obj_tables/io.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_ordered_attributes has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_ordered_attributes(cls, include_all_attributes=True):
                  """ Get the attributes for a class in the order that they should be printed
              
                  Args:
                      cls (:obj:`type`): Model type (subclass of :obj:`Model`)
              Severity: Minor
              Found in obj_tables/io.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

              Consider simplifying this complex logical expression.
              Open

                          if not row or all(cell in ['', None] for cell in row):
                              rows.remove(row)
                          elif row and isinstance(row[0], str) and \
                                  row[0].startswith('%/') and row[0].endswith('/%') and \
                                  not any(row[1:]):
              Severity: Critical
              Found in obj_tables/io.py - About 2 hrs to fix

                Function create_template has 16 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def create_template(path, schema_name, models, title=None, description=None, keywords=None,
                Severity: Major
                Found in obj_tables/io.py - About 2 hrs to fix

                  Function write_model has 15 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def write_model(self, writer, model, objects, schema_name, date, doc_metadata, doc_metadata_model, model_metadata, sheet_models,
                  Severity: Major
                  Found in obj_tables/io.py - About 1 hr to fix

                    Function run has 14 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def run(self, path, schema_name=None, models=None,
                    Severity: Major
                    Found in obj_tables/io.py - About 1 hr to fix

                      Function get_fields has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def get_fields(cls, schema_name, date, doc_metadata, doc_metadata_model, model_metadata, include_all_attributes=True, sheet_models=None):
                          """ Get the attributes, headings, and validation for a worksheet
                      
                          Args:
                              cls (:obj:`type`): Model type (subclass of :obj:`Model`)
                      Severity: Minor
                      Found in obj_tables/io.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 run has 14 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def run(self, path, schema_name=None, models=None,
                      Severity: Major
                      Found in obj_tables/io.py - About 1 hr to fix

                        Function run has 14 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def run(self, path, schema_name=None, models=None,
                        Severity: Major
                        Found in obj_tables/io.py - About 1 hr to fix

                          Function convert has 14 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          def convert(source, destination, schema_name=None, models=None,
                          Severity: Major
                          Found in obj_tables/io.py - About 1 hr to fix

                            Function run has 14 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                def run(self, path, schema_name=None, models=None,
                            Severity: Major
                            Found in obj_tables/io.py - About 1 hr to fix

                              Function run has 14 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  def run(self, path, schema_name=None, models=None,
                              Severity: Major
                              Found in obj_tables/io.py - About 1 hr to fix

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

                                    def write_sheet(self, writer, model, data, headings, metadata_headings, validation,
                                                    extra_entries=0, merge_ranges=None, protected=False):
                                        """ Write data to sheet
                                
                                        Args:
                                Severity: Minor
                                Found in obj_tables/io.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 run has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    def run(self, path, schema_name=None, models=None,
                                            allow_multiple_sheets_per_model=False,
                                            ignore_missing_models=False, ignore_extra_models=False,
                                            ignore_sheet_order=False,
                                            include_all_attributes=True, ignore_missing_attributes=False, ignore_extra_attributes=False,
                                Severity: Minor
                                Found in obj_tables/io.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 run has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    def run(self, path, schema_name=None, models=None,
                                            allow_multiple_sheets_per_model=False,
                                            ignore_missing_models=False, ignore_extra_models=False,
                                            ignore_sheet_order=False,
                                            include_all_attributes=True, ignore_missing_attributes=False, ignore_extra_attributes=False,
                                Severity: Minor
                                Found in obj_tables/io.py - About 1 hr to fix

                                  Function get_fields has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  def get_fields(cls, schema_name, date, doc_metadata, doc_metadata_model, model_metadata, include_all_attributes=True, sheet_models=None):
                                      """ Get the attributes, headings, and validation for a worksheet
                                  
                                      Args:
                                          cls (:obj:`type`): Model type (subclass of :obj:`Model`)
                                  Severity: Minor
                                  Found in obj_tables/io.py - About 1 hr to fix

                                    Function make_metadata_objects has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        def make_metadata_objects(self, data_repo_metadata, path, schema_package):
                                            """ Make models that store Git repository metadata
                                    
                                            Metadata models can only be created from suitable Git repos.
                                            Failures to obtain metadata are reported as warnings that do not interfeer with writing
                                    Severity: Minor
                                    Found in obj_tables/io.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 read_model has 10 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                        def read_model(self, reader, sheet_name, schema_name, model, include_all_attributes=True,
                                    Severity: Major
                                    Found in obj_tables/io.py - About 1 hr to fix

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

                                          def write_toc(self, writer, models, schema_name, date, doc_metadata, grouped_objects, write_schema=False, protected=True):
                                              """ Write a worksheet with a table of contents
                                      
                                              Args:
                                                  writer (:obj:`wc_utils.workbook.io.Writer`): io writer
                                      Severity: Minor
                                      Found in obj_tables/io.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 write_sheet has 9 arguments (exceeds 4 allowed). Consider refactoring.
                                      Open

                                          def write_sheet(self, writer, model, data, headings, metadata_headings, validation,
                                      Severity: Major
                                      Found in obj_tables/io.py - About 1 hr to fix

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

                                            def write_sheet(self, writer, model, data, headings, metadata_headings, validation,
                                        Severity: Major
                                        Found in obj_tables/io.py - About 1 hr to fix

                                          Function run has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                          Open

                                              def run(self, path, objects, schema_name=None, doc_metadata=None, model_metadata=None,
                                                      models=None, get_related=True, include_all_attributes=True, validate=True,
                                                      title=None, description=None, keywords=None, version=None, language=None, creator=None,
                                                      write_toc=True, write_schema=False, write_empty_models=True, write_empty_cols=True,
                                                      extra_entries=0, group_objects_by_model=True, data_repo_metadata=False, schema_package=None,
                                          Severity: Minor
                                          Found in obj_tables/io.py - About 1 hr to fix

                                            Function write_toc has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                            Open

                                                def write_toc(self, writer, models, schema_name, date, doc_metadata, grouped_objects, write_schema=False, protected=True):
                                            Severity: Major
                                            Found in obj_tables/io.py - About 1 hr to fix

                                              Function get_fields has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                              Open

                                              def get_fields(cls, schema_name, date, doc_metadata, doc_metadata_model, model_metadata, include_all_attributes=True, sheet_models=None):
                                              Severity: Major
                                              Found in obj_tables/io.py - About 1 hr to fix

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

                                                    def read_sheet(self, model, reader, sheet_name, num_row_heading_columns=0, num_column_heading_rows=0,
                                                Severity: Major
                                                Found in obj_tables/io.py - About 50 mins to fix

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

                                                      def run(self, objects, schema_name=None, models=None, get_related=True,
                                                  Severity: Major
                                                  Found in obj_tables/io.py - About 50 mins to fix

                                                    Avoid deeply nested control flow statements.
                                                    Open

                                                                            if same_val:
                                                                                for sub_attr in attr.related_class.Meta.attributes.values():
                                                                                    sub_val = getattr(val, sub_attr.name)
                                                                                    if isinstance(sub_val, list):
                                                                                        setattr(val, sub_attr.name, [])
                                                    Severity: Major
                                                    Found in obj_tables/io.py - About 45 mins to fix

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

                                                          def get_model_sheet_name(cls, sheet_names, model):
                                                              """ Get the name of the worksheet/file which corresponds to a model
                                                      
                                                              Args:
                                                                  sheet_names (:obj:`list` of :obj:`str`): names of the sheets in the workbook/files
                                                      Severity: Minor
                                                      Found in obj_tables/io.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 merged_model_metadata[model][key] != val:
                                                                                  errors.append('Attribute "{}" for model "{}" is not consistent'.format(
                                                                                      key, model.__name__, ))
                                                                          else:
                                                      Severity: Major
                                                      Found in obj_tables/io.py - About 45 mins to fix

                                                        Avoid deeply nested control flow statements.
                                                        Open

                                                                                    if deserialize_error:
                                                                                        deserialize_error.set_location_and_value(utils.source_report(obj, sub_attr.name),
                                                                                                                                 attr_value)
                                                                                        obj_errors.append(deserialize_error)
                                                                                    if validation_error:
                                                        Severity: Major
                                                        Found in obj_tables/io.py - About 45 mins to fix

                                                          Avoid deeply nested control flow statements.
                                                          Open

                                                                                  if attr.related_class not in objects_by_primary_attribute:
                                                                                      objects_by_primary_attribute[attr.related_class] = {}
                                                                                  serialized_val = val.serialize()
                                                          Severity: Major
                                                          Found in obj_tables/io.py - About 45 mins to fix

                                                            Avoid deeply nested control flow statements.
                                                            Open

                                                                                        if validation_error:
                                                                                            validation_error.set_location_and_value(utils.source_report(obj, sub_attr.name),
                                                                                                                                    attr_value)
                                                                                            obj_errors.append(validation_error)
                                                                                    setattr(obj, sub_attr.name, value)
                                                            Severity: Major
                                                            Found in obj_tables/io.py - About 45 mins to fix

                                                              Avoid deeply nested control flow statements.
                                                              Open

                                                                                      if is_col_empty:
                                                                                          row.pop(i_col)
                                                              
                                                              
                                                              Severity: Major
                                                              Found in obj_tables/io.py - About 45 mins to fix

                                                                Avoid deeply nested control flow statements.
                                                                Open

                                                                                        if not sub_obj:
                                                                                            sub_obj = group_attr.related_class()
                                                                                            setattr(obj, group_attr.name, sub_obj)
                                                                                        setattr(sub_obj, sub_attr.name, value)
                                                                Severity: Major
                                                                Found in obj_tables/io.py - About 45 mins to fix

                                                                  Avoid deeply nested control flow statements.
                                                                  Open

                                                                                          for sub_attr in sub_attrs:
                                                                                              if val:
                                                                                                  sub_val = getattr(val, sub_attr.name)
                                                                                                  if isinstance(sub_attr, RelatedAttribute):
                                                                                                      obj_data.append(sub_attr.serialize(sub_val, encoded=encoded))
                                                                  Severity: Major
                                                                  Found in obj_tables/io.py - About 45 mins to fix

                                                                    Avoid deeply nested control flow statements.
                                                                    Open

                                                                                            if not line.startswith('!!!'):
                                                                                                out_file.write(line)
                                                                                    if i_path < len(all_tmp_paths) - 1:
                                                                    Severity: Major
                                                                    Found in obj_tables/io.py - About 45 mins to fix

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

                                                                          def write_schema(self, writer, models, name, date, doc_metadata, protected=True):
                                                                      Severity: Minor
                                                                      Found in obj_tables/io.py - About 45 mins to fix

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

                                                                            def link_model(self, model, attributes, data, objects, objects_by_primary_attribute, decoded=None):
                                                                        Severity: Minor
                                                                        Found in obj_tables/io.py - About 45 mins to fix

                                                                          Avoid too many return statements within this function.
                                                                          Open

                                                                                  return (sub_attrs, data, errors, objects)
                                                                          Severity: Major
                                                                          Found in obj_tables/io.py - About 30 mins to fix

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

                                                                                def parse_worksheet_heading_metadata(cls, heading, sheet_name=None):
                                                                                    """ Parse key-value pairs of metadata from heading
                                                                            
                                                                                    Args:
                                                                                        heading (:obj:`str`): heading with key-value pairs of metadata
                                                                            Severity: Minor
                                                                            Found in obj_tables/io.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

                                                                            There are no issues that match your filters.

                                                                            Category
                                                                            Status