mwielgoszewski/doorman

View on GitHub
doorman/models.py

Summary

Maintainability
F
5 days
Test Coverage

File models.py has 443 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
import datetime as dt
import string
import uuid

Severity: Minor
Found in doorman/models.py - About 6 hrs to fix

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

        def __init__(self, name, query=None, sql=None, interval=3600, platform=None,
    Severity: Major
    Found in doorman/models.py - About 1 hr to fix

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

          def __init__(self, line=None, message=None, severity=None,
      Severity: Major
      Found in doorman/models.py - About 1 hr to fix

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

            def __init__(self, host_identifier, node_key=None,
        Severity: Major
        Found in doorman/models.py - About 1 hr to fix

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

              def __init__(self, name=None, action=None, columns=None, timestamp=None,
          Severity: Major
          Found in doorman/models.py - About 50 mins to fix

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

                def __init__(self, name, platform=None, version=None,
            Severity: Minor
            Found in doorman/models.py - About 45 mins to fix

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

                  def __init__(self, username, password=None, email=None, social_id=None,
              Severity: Minor
              Found in doorman/models.py - About 45 mins to fix

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

                    def __init__(self, name, alerters, description=None, conditions=None, updated_at=None):
                Severity: Minor
                Found in doorman/models.py - About 35 mins to fix

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

                      @property
                      def queries(self):
                          return db.session.object_session(self) \
                              .query(Query) \
                              .join(query_tags, query_tags.c['query.id'] == Query.id) \
                  Severity: Major
                  Found in doorman/models.py and 2 other locations - About 6 hrs to fix
                  doorman/models.py on lines 268..275
                  doorman/models.py on lines 286..293

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

                  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 3 locations. Consider refactoring.
                  Open

                      @property
                      def file_paths(self):
                          return db.session.object_session(self) \
                              .query(FilePath) \
                              .join(file_path_tags, file_path_tags.c['file_path.id'] == FilePath.id) \
                  Severity: Major
                  Found in doorman/models.py and 2 other locations - About 6 hrs to fix
                  doorman/models.py on lines 268..275
                  doorman/models.py on lines 277..284

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

                  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 3 locations. Consider refactoring.
                  Open

                      @property
                      def packs(self):
                          return db.session.object_session(self) \
                              .query(Pack) \
                              .join(pack_tags, pack_tags.c['pack.id'] == Pack.id) \
                  Severity: Major
                  Found in doorman/models.py and 2 other locations - About 6 hrs to fix
                  doorman/models.py on lines 277..284
                  doorman/models.py on lines 286..293

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

                  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 4 locations. Consider refactoring.
                  Open

                  node_tags = Table(
                      'node_tags',
                      Column('tag.id', db.Integer, ForeignKey('tag.id')),
                      Column('node.id', db.Integer, ForeignKey('node.id'), index=True)
                  Severity: Major
                  Found in doorman/models.py and 3 other locations - About 45 mins to fix
                  doorman/models.py on lines 32..35
                  doorman/models.py on lines 44..47
                  doorman/models.py on lines 50..53

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

                  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 4 locations. Consider refactoring.
                  Open

                  file_path_tags = Table(
                      'file_path_tags',
                      Column('tag.id', db.Integer, ForeignKey('tag.id')),
                      Column('file_path.id', db.Integer, ForeignKey('file_path.id'), index=True)
                  Severity: Major
                  Found in doorman/models.py and 3 other locations - About 45 mins to fix
                  doorman/models.py on lines 32..35
                  doorman/models.py on lines 38..41
                  doorman/models.py on lines 44..47

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

                  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 4 locations. Consider refactoring.
                  Open

                  pack_tags = Table(
                      'pack_tags',
                      Column('tag.id', db.Integer, ForeignKey('tag.id')),
                      Column('pack.id', db.Integer, ForeignKey('pack.id'), index=True)
                  Severity: Major
                  Found in doorman/models.py and 3 other locations - About 45 mins to fix
                  doorman/models.py on lines 38..41
                  doorman/models.py on lines 44..47
                  doorman/models.py on lines 50..53

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

                  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 4 locations. Consider refactoring.
                  Open

                  query_tags = Table(
                      'query_tags',
                      Column('tag.id', db.Integer, ForeignKey('tag.id')),
                      Column('query.id', db.Integer, ForeignKey('query.id'), index=True)
                  Severity: Major
                  Found in doorman/models.py and 3 other locations - About 45 mins to fix
                  doorman/models.py on lines 32..35
                  doorman/models.py on lines 38..41
                  doorman/models.py on lines 50..53

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

                  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 4 locations. Consider refactoring.
                  Open

                      @property
                      def packs_count(self):
                          return db.session.object_session(self) \
                              .query(Pack.id).with_parent(self, 'packs').count()
                  Severity: Major
                  Found in doorman/models.py and 3 other locations - About 40 mins to fix
                  doorman/models.py on lines 96..99
                  doorman/models.py on lines 101..104
                  doorman/models.py on lines 106..109

                  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 4 locations. Consider refactoring.
                  Open

                      @property
                      def nodes_count(self):
                          return db.session.object_session(self) \
                              .query(Node.id).with_parent(self, 'nodes').count()
                  Severity: Major
                  Found in doorman/models.py and 3 other locations - About 40 mins to fix
                  doorman/models.py on lines 91..94
                  doorman/models.py on lines 101..104
                  doorman/models.py on lines 106..109

                  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 4 locations. Consider refactoring.
                  Open

                      @property
                      def queries_count(self):
                          return db.session.object_session(self) \
                              .query(Query.id).with_parent(self, 'queries').count()
                  Severity: Major
                  Found in doorman/models.py and 3 other locations - About 40 mins to fix
                  doorman/models.py on lines 91..94
                  doorman/models.py on lines 96..99
                  doorman/models.py on lines 106..109

                  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 4 locations. Consider refactoring.
                  Open

                      @property
                      def file_paths_count(self):
                          return db.session.object_session(self) \
                              .query(FilePath.id).with_parent(self, 'file_paths').count()
                  Severity: Major
                  Found in doorman/models.py and 3 other locations - About 40 mins to fix
                  doorman/models.py on lines 91..94
                  doorman/models.py on lines 96..99
                  doorman/models.py on lines 101..104

                  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 __init__(self, name, platform=None, version=None,
                                   description=None, shard=None, **kwargs):
                          self.name = name
                          self.platform = platform
                          self.version = version
                  Severity: Minor
                  Found in doorman/models.py and 1 other location - About 30 mins to fix
                  doorman/models.py on lines 504..509

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

                  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, name, alerters, description=None, conditions=None, updated_at=None):
                          self.name = name
                          self.description = description
                          self.alerters = alerters
                          self.conditions = conditions
                  Severity: Minor
                  Found in doorman/models.py and 1 other location - About 30 mins to fix
                  doorman/models.py on lines 186..192

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

                  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

                  Continuation line under-indented for visual indent
                  Open

                                  'node_id', cls.created.desc()),
                  Severity: Minor
                  Found in doorman/models.py by pep8

                  Continuation lines indentation.

                  Continuation lines should align wrapped elements either vertically
                  using Python's implicit line joining inside parentheses, brackets
                  and braces, or using a hanging indent.
                  
                  When using a hanging indent these considerations should be applied:
                  - there should be no arguments on the first line, and
                  - further indentation should be used to clearly distinguish itself
                    as a continuation line.
                  
                  Okay: a = (\n)
                  E123: a = (\n    )
                  
                  Okay: a = (\n    42)
                  E121: a = (\n   42)
                  E122: a = (\n42)
                  E123: a = (\n    42\n    )
                  E124: a = (24,\n     42\n)
                  E125: if (\n    b):\n    pass
                  E126: a = (\n        42)
                  E127: a = (24,\n      42)
                  E128: a = (24,\n    42)
                  E129: if (a or\n    b):\n    pass
                  E131: a = (\n    42\n 24)

                  There are no issues that match your filters.

                  Category
                  Status