HumanLearning2021/HumanLearningApp

View on GitHub
app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt

Summary

Maintainability
A
0 mins
Test Coverage
A
100%

Class DefaultDatabaseManagement has 24 methods (exceeds 20 allowed). Consider refactoring.
Invalid

/**
 * Wraps a DatabaseService
 * @property databaseService providing the entry point to the underlying database
 */
class DefaultDatabaseManagement internal constructor(

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

        override suspend fun getCategoryByName(categoryName: String): Collection<Category> {
            val categories = databaseService.getCategories()
            val res: MutableSet<Category> = mutableSetOf()
            for (c in categories) {
                if (c.name == categoryName) {
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 102..111

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

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

        override suspend fun getDatasetByName(datasetName: String): Collection<Dataset> {
            val datasets = databaseService.getDatasets()
            val res: MutableSet<Dataset> = mutableSetOf()
            for (d in datasets) {
                if (d.name == datasetName) {
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 51..60

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

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

        override suspend fun getDatasetIds(): Set<Id> {
            val datasets = databaseService.getDatasets()
            val res: MutableSet<String> = mutableSetOf()
            for (d in datasets) {
                res.add(d.id)
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 137..144

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

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

        override suspend fun getDatasetNames(): Collection<String> {
            val datasets = databaseService.getDatasets()
            val res: MutableSet<String> = mutableSetOf()
            for (d in datasets) {
                res.add(d.name)
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 146..153

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

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

        override suspend fun editDatasetName(dataset: Dataset, newName: String): Dataset {
            return try {
                databaseService.editDatasetName(dataset, newName)
            } catch (e: DatabaseService.NotFoundException) {
                throw e
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 39..45
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 155..161
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 171..177

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

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

        override suspend fun removeCategoryFromDataset(dataset: Dataset, category: Category): Dataset {
            return try {
                databaseService.removeCategoryFromDataset(dataset, category)
            } catch (e: DatabaseService.NotFoundException) {
                throw e
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 39..45
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 163..169
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 171..177

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

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

        override suspend fun addCategoryToDataset(dataset: Dataset, category: Category): Dataset {
            return try {
                databaseService.addCategoryToDataset(dataset, category)
            } catch (e: DatabaseService.NotFoundException) {
                throw e
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 39..45
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 155..161
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 163..169

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

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

        override suspend fun putPicture(picture: Uri, category: Category): CategorizedPicture {
            return try {
                databaseService.putPicture(picture, category)
            } catch (e: DatabaseService.NotFoundException) {
                throw e
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 155..161
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 163..169
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 171..177

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

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

        override suspend fun getAllPictures(category: Category): Set<CategorizedPicture> {
            return try {
                databaseService.getAllPictures(category)
            } catch (e: DatabaseService.NotFoundException) {
                throw e
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 27..33

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

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

        override suspend fun getPictureIds(category: Category): List<Id> {
            return try {
                databaseService.getPictureIds(category)
            } catch (e: DatabaseService.NotFoundException) {
                throw e
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 70..76

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

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

        override suspend fun removePicture(picture: CategorizedPicture) {
            try {
                databaseService.removePicture(picture)
            } catch (e: DatabaseService.NotFoundException) {
                //do nothing since this means that the picture is not in the database which is the same as having it removed
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 78..84
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 113..119

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

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

        override suspend fun deleteDataset(id: Id) {
            try {
                databaseService.deleteDataset(id)
            } catch (e: DatabaseService.NotFoundException) {
                //do nothing since this means that the dataset is not in the database which is the same as having it removed
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 78..84
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 86..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 66.

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

        override suspend fun removeCategory(category: Category) {
            try {
                databaseService.removeCategory(category)
            } catch (e: DatabaseService.NotFoundException) {
                //do nothing since this means that the category is not in the database which is the same as having it removed
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 86..92
    app/src/main/java/com/github/HumanLearning2021/HumanLearningApp/model/DefaultDatabaseManagement.kt on lines 113..119

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

    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