davidlatwe/MontyDB

View on GitHub
montydb/storage/sqlite.py

Summary

Maintainability
F
3 days
Test Coverage

File sqlite.py has 347 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import os
import shutil
import sqlite3
import contextlib
from collections import OrderedDict
Severity: Minor
Found in montydb/storage/sqlite.py - About 4 hrs to fix

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

        def wconcern_parser(self,
    Severity: Minor
    Found in montydb/storage/sqlite.py - About 35 mins to fix

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

          def collection_list(self):
              if not self.database_exists():
                  return []
              return [os.path.splitext(name)[0]
                      for name in os.listdir(unicode_(self._db_path))]
      Severity: Major
      Found in montydb/storage/sqlite.py and 1 other location - About 2 hrs to fix
      montydb/storage/flatfile.py on lines 188..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 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

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

          def _ensure_table(func):
              def make_table(self, *args, **kwargs):
                  if not self._database.collection_exists(self._name):
                      self._database.collection_create(self._name)
                  return func(self, *args, **kwargs)
      Severity: Major
      Found in montydb/storage/sqlite.py and 1 other location - About 2 hrs to fix
      montydb/storage/flatfile.py on lines 215..220

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

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

          def update_one(self, db_file, params, wconcern=None):
              with self._connect(db_file, wconcern) as conn:
                  with conn:
                      sql = UPDATE_RECORD.format(SQLITE_RECORD_TABLE)
                      conn.execute(sql, params)
      Severity: Major
      Found in montydb/storage/sqlite.py and 5 other locations - About 1 hr to fix
      montydb/storage/sqlite.py on lines 139..143
      montydb/storage/sqlite.py on lines 145..149
      montydb/storage/sqlite.py on lines 157..161
      montydb/storage/sqlite.py on lines 163..167
      montydb/storage/sqlite.py on lines 169..173

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

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

          def update_many(self, db_file, seq_params, wconcern=None):
              with self._connect(db_file, wconcern) as conn:
                  with conn:
                      sql = UPDATE_RECORD.format(SQLITE_RECORD_TABLE)
                      conn.executemany(sql, seq_params)
      Severity: Major
      Found in montydb/storage/sqlite.py and 5 other locations - About 1 hr to fix
      montydb/storage/sqlite.py on lines 139..143
      montydb/storage/sqlite.py on lines 145..149
      montydb/storage/sqlite.py on lines 151..155
      montydb/storage/sqlite.py on lines 163..167
      montydb/storage/sqlite.py on lines 169..173

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

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

          def delete_many(self, db_file, seq_params, wconcern=None):
              with self._connect(db_file, wconcern) as conn:
                  with conn:
                      sql = DELETE_RECORD.format(SQLITE_RECORD_TABLE)
                      conn.executemany(sql, seq_params)
      Severity: Major
      Found in montydb/storage/sqlite.py and 5 other locations - About 1 hr to fix
      montydb/storage/sqlite.py on lines 139..143
      montydb/storage/sqlite.py on lines 145..149
      montydb/storage/sqlite.py on lines 151..155
      montydb/storage/sqlite.py on lines 157..161
      montydb/storage/sqlite.py on lines 163..167

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

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

          def delete_one(self, db_file, params, wconcern=None):
              with self._connect(db_file, wconcern) as conn:
                  with conn:
                      sql = DELETE_RECORD.format(SQLITE_RECORD_TABLE)
                      conn.execute(sql, params)
      Severity: Major
      Found in montydb/storage/sqlite.py and 5 other locations - About 1 hr to fix
      montydb/storage/sqlite.py on lines 139..143
      montydb/storage/sqlite.py on lines 145..149
      montydb/storage/sqlite.py on lines 151..155
      montydb/storage/sqlite.py on lines 157..161
      montydb/storage/sqlite.py on lines 169..173

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

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

          def write_one(self, db_file, params, wconcern=None):
              with self._connect(db_file, wconcern) as conn:
                  with conn:
                      sql = INSERT_RECORD.format(SQLITE_RECORD_TABLE)
                      conn.execute(sql, params)
      Severity: Major
      Found in montydb/storage/sqlite.py and 5 other locations - About 1 hr to fix
      montydb/storage/sqlite.py on lines 145..149
      montydb/storage/sqlite.py on lines 151..155
      montydb/storage/sqlite.py on lines 157..161
      montydb/storage/sqlite.py on lines 163..167
      montydb/storage/sqlite.py on lines 169..173

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

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

          def write_many(self, db_file, seq_params, wconcern=None):
              with self._connect(db_file, wconcern) as conn:
                  with conn:
                      sql = INSERT_RECORD.format(SQLITE_RECORD_TABLE)
                      conn.executemany(sql, seq_params)
      Severity: Major
      Found in montydb/storage/sqlite.py and 5 other locations - About 1 hr to fix
      montydb/storage/sqlite.py on lines 139..143
      montydb/storage/sqlite.py on lines 151..155
      montydb/storage/sqlite.py on lines 157..161
      montydb/storage/sqlite.py on lines 163..167
      montydb/storage/sqlite.py on lines 169..173

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

      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

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

          def database_list(self):
              return [
                  name for name in os.listdir(unicode_(self._repository))
                  if os.path.isdir(self._db_path(name))
      Severity: Major
      Found in montydb/storage/sqlite.py and 2 other locations - About 1 hr to fix
      montydb/storage/flatfile.py on lines 144..147
      montydb/storage/lightning.py on lines 123..126

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

      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

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

          def database_create(self, db_name):
              if not os.path.isdir(self._db_path(db_name)):
                  os.makedirs(self._db_path(db_name))
      Severity: Major
      Found in montydb/storage/sqlite.py and 2 other locations - About 1 hr to fix
      montydb/storage/flatfile.py on lines 133..135
      montydb/storage/lightning.py on lines 114..116

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

      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

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

          def database_drop(self, db_name):
              db_path = self._db_path(db_name)
              if os.path.isdir(db_path):
                  shutil.rmtree(db_path)
      Severity: Major
      Found in montydb/storage/sqlite.py and 1 other location - About 1 hr to fix
      montydb/storage/lightning.py on lines 118..121

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

          def __init__(self, repository, storage_config):
              super(SQLiteStorage, self).__init__(repository, storage_config)
              self._conn = SQLiteKVEngine(self._config)
      Severity: Minor
      Found in montydb/storage/sqlite.py and 1 other location - About 50 mins to fix
      montydb/storage/lightning.py on lines 92..94

      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

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

          def collection_drop(self, col_name):
              if self.collection_exists(col_name):
                  os.remove(self._col_path(col_name))
      Severity: Minor
      Found in montydb/storage/sqlite.py and 1 other location - About 30 mins to fix
      montydb/storage/lightning.py on lines 159..161

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

      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