dxania/Send_IT_APIs

View on GitHub
app/controllers/db.py

Summary

Maintainability
D
2 days
Test Coverage

DatabaseConnection has 26 functions (exceeds 20 allowed). Consider refactoring.
Open

class DatabaseConnection:
    def __init__(self):

#         db = 'd8l5eq5eakmkcm'
        db = 'sendit'
Severity: Minor
Found in app/controllers/db.py - About 3 hrs to fix

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

        def add_parcel(self, description, user_id, user_name, recipient_name, recipient_mobile, pickup_location, destination, weight, total_price):
    Severity: Major
    Found in app/controllers/db.py - About 1 hr to fix

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

          def select_no_of_user_parcels_intransit(self, username):
              query = "SELECT COUNT(user_name) FROM parcels WHERE user_name = '{}' and status = 'intransit'".format(username)
              self.cursor.execute(query)
              result = self.cursor.fetchall()
              return result
      Severity: Major
      Found in app/controllers/db.py and 8 other locations - About 1 hr to fix
      app/controllers/db.py on lines 94..98
      app/controllers/db.py on lines 106..110
      app/controllers/db.py on lines 126..130
      app/controllers/db.py on lines 132..136
      app/controllers/db.py on lines 157..161
      app/controllers/db.py on lines 163..167
      app/controllers/db.py on lines 169..173
      app/controllers/db.py on lines 181..185

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

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

          def get_a_parcel(self, parcel_id):
              get_parcel = "SELECT * FROM parcels WHERE parcel_id = '{}'".format(parcel_id)
              self.cursor.execute(get_parcel)
              result = self.cursor.fetchone()
              return result
      Severity: Major
      Found in app/controllers/db.py and 8 other locations - About 1 hr to fix
      app/controllers/db.py on lines 106..110
      app/controllers/db.py on lines 126..130
      app/controllers/db.py on lines 132..136
      app/controllers/db.py on lines 157..161
      app/controllers/db.py on lines 163..167
      app/controllers/db.py on lines 169..173
      app/controllers/db.py on lines 175..179
      app/controllers/db.py on lines 181..185

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

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

          def select_no_of_user_parcels_delivered(self, username):
              query = "SELECT COUNT(user_name) FROM parcels WHERE user_name = '{}' and status = 'delivered'".format(username)
              self.cursor.execute(query)
              result = self.cursor.fetchone()
              return result
      Severity: Major
      Found in app/controllers/db.py and 8 other locations - About 1 hr to fix
      app/controllers/db.py on lines 94..98
      app/controllers/db.py on lines 106..110
      app/controllers/db.py on lines 126..130
      app/controllers/db.py on lines 132..136
      app/controllers/db.py on lines 157..161
      app/controllers/db.py on lines 163..167
      app/controllers/db.py on lines 169..173
      app/controllers/db.py on lines 175..179

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

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

          def get_user_by_id(self, user_id):
              get_user = "SELECT * FROM users WHERE user_id = '{}'".format(user_id)
              self.cursor.execute(get_user)
              result = self.cursor.fetchone()
              return result
      Severity: Major
      Found in app/controllers/db.py and 8 other locations - About 1 hr to fix
      app/controllers/db.py on lines 94..98
      app/controllers/db.py on lines 106..110
      app/controllers/db.py on lines 126..130
      app/controllers/db.py on lines 157..161
      app/controllers/db.py on lines 163..167
      app/controllers/db.py on lines 169..173
      app/controllers/db.py on lines 175..179
      app/controllers/db.py on lines 181..185

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

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

          def get_user(self, user_name):
              get_user = "SELECT * FROM users WHERE user_name = '{}'".format(user_name)
              self.cursor.execute(get_user)
              result = self.cursor.fetchone()
              return result
      Severity: Major
      Found in app/controllers/db.py and 8 other locations - About 1 hr to fix
      app/controllers/db.py on lines 94..98
      app/controllers/db.py on lines 106..110
      app/controllers/db.py on lines 132..136
      app/controllers/db.py on lines 157..161
      app/controllers/db.py on lines 163..167
      app/controllers/db.py on lines 169..173
      app/controllers/db.py on lines 175..179
      app/controllers/db.py on lines 181..185

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

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

          def get_parcels_by_user(self, user_id):
              get_user_parcels = "SELECT * FROM parcels WHERE user_id = '{}' ORDER BY parcel_id ASC".format(user_id)
              self.cursor.execute(get_user_parcels)
              result = self.cursor.fetchall()
              return result
      Severity: Major
      Found in app/controllers/db.py and 8 other locations - About 1 hr to fix
      app/controllers/db.py on lines 94..98
      app/controllers/db.py on lines 126..130
      app/controllers/db.py on lines 132..136
      app/controllers/db.py on lines 157..161
      app/controllers/db.py on lines 163..167
      app/controllers/db.py on lines 169..173
      app/controllers/db.py on lines 175..179
      app/controllers/db.py on lines 181..185

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

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

          def select_no_of_user_parcels_cancelled(self, username):
              query = "SELECT COUNT(user_name) FROM parcels WHERE user_name = '{}' and status = 'cancelled'".format(username)
              self.cursor.execute(query)
              result = self.cursor.fetchone()
              return result
      Severity: Major
      Found in app/controllers/db.py and 8 other locations - About 1 hr to fix
      app/controllers/db.py on lines 94..98
      app/controllers/db.py on lines 106..110
      app/controllers/db.py on lines 126..130
      app/controllers/db.py on lines 132..136
      app/controllers/db.py on lines 157..161
      app/controllers/db.py on lines 169..173
      app/controllers/db.py on lines 175..179
      app/controllers/db.py on lines 181..185

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

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

          def select_no_of_user_parcels(self, username):
              query = "SELECT COUNT(user_name) FROM parcels WHERE user_name = '{}'".format(username)
              self.cursor.execute(query)
              result = self.cursor.fetchone()
              return result
      Severity: Major
      Found in app/controllers/db.py and 8 other locations - About 1 hr to fix
      app/controllers/db.py on lines 94..98
      app/controllers/db.py on lines 106..110
      app/controllers/db.py on lines 126..130
      app/controllers/db.py on lines 132..136
      app/controllers/db.py on lines 163..167
      app/controllers/db.py on lines 169..173
      app/controllers/db.py on lines 175..179
      app/controllers/db.py on lines 181..185

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

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

          def select_no_of_user_parcels_pending(self, username):
              query = "SELECT COUNT(user_name) FROM parcels WHERE user_name = '{}' and status = 'pending'".format(username)
              self.cursor.execute(query)
              result = self.cursor.fetchone()
              return result
      Severity: Major
      Found in app/controllers/db.py and 8 other locations - About 1 hr to fix
      app/controllers/db.py on lines 94..98
      app/controllers/db.py on lines 106..110
      app/controllers/db.py on lines 126..130
      app/controllers/db.py on lines 132..136
      app/controllers/db.py on lines 157..161
      app/controllers/db.py on lines 163..167
      app/controllers/db.py on lines 175..179
      app/controllers/db.py on lines 181..185

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

      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 get_users(self):
              get_users = "SELECT * FROM users ORDER BY user_id ASC"
              self.cursor.execute(get_users)
              result = self.cursor.fetchall()
              return result
      Severity: Minor
      Found in app/controllers/db.py and 1 other location - About 50 mins to fix
      app/controllers/db.py on lines 88..92

      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 get_all_parcels(self):
              get_parcels = "SELECT * FROM parcels ORDER BY parcel_id ASC"
              self.cursor.execute(get_parcels)
              result = self.cursor.fetchall()
              return result
      Severity: Minor
      Found in app/controllers/db.py and 1 other location - About 50 mins to fix
      app/controllers/db.py on lines 138..142

      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

      There are no issues that match your filters.

      Category
      Status