odin-detector/odin-data

View on GitHub
python/src/odin_data/meta_writer/meta_writer.py

Summary

Maintainability
D
2 days
Test Coverage

File meta_writer.py has 438 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Implementation of odin_data Meta Writer

This module is passed meta data messages for a single acquisition which it writes to disk.
Will need to be subclassed by detector specific implementation.

Severity: Minor
Found in python/src/odin_data/meta_writer/meta_writer.py - About 6 hrs to fix

    MetaWriter has 31 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class MetaWriter(object):
        """This class handles meta data messages and writes parameters to disk"""
    
        FILE_SUFFIX = "_meta.h5"
        CONFIGURE_PARAMETERS = [
    Severity: Minor
    Found in python/src/odin_data/meta_writer/meta_writer.py - About 3 hrs to fix

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

          def _create_datasets(self, dataset_size):
              """Add predefined datasets to HDF5 file and store handles
      
              Args:
                  datasets(list(HDF5Dataset)): The datasets to add to the file
      Severity: Minor
      Found in python/src/odin_data/meta_writer/meta_writer.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

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

          def stop_when_detector_finished(self):
              """Register that it is OK to stop when all detector-specific logic is complete
      
              By default, detector_finished is set to True initially so that this check always
              passes. Child classes that need to do their own checks can set this to False in
      Severity: Major
      Found in python/src/odin_data/meta_writer/meta_writer.py and 1 other location - About 2 hrs to fix
      python/src/odin_data/meta_writer/meta_writer.py on lines 356..367

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

      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 stop_when_writers_finished(self):
              """Register that it is OK to stop when all monitored writers have finished
      
              Child classes can call this when all detector-specific logic is complete.
      
      
      Severity: Major
      Found in python/src/odin_data/meta_writer/meta_writer.py and 1 other location - About 2 hrs to fix
      python/src/odin_data/meta_writer/meta_writer.py on lines 341..354

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

      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 handle_close_file(self, _header, data):
              self._logger.debug("%s | Handling close file message", self._name)
      
              self._add_value(CLOSE_DURATION, data[CLOSE_DURATION])
      Severity: Major
      Found in python/src/odin_data/meta_writer/meta_writer.py and 1 other location - About 1 hr to fix
      python/src/odin_data/meta_writer/meta_writer.py on lines 499..502

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

      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 handle_create_file(self, _header, data):
              self._logger.debug("%s | Handling create file message", self._name)
      
              self._add_value(CREATE_DURATION, data[CREATE_DURATION])
      Severity: Major
      Found in python/src/odin_data/meta_writer/meta_writer.py and 1 other location - About 1 hr to fix
      python/src/odin_data/meta_writer/meta_writer.py on lines 558..561

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

      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

      There are no issues that match your filters.

      Category
      Status