yahoo/kobold-core

View on GitHub
lib/storageAdapter/keyValueStorageAdapter.js

Summary

Maintainability
F
6 days
Test Coverage

KeyValueStorageAdapter has 27 functions (exceeds 20 allowed). Consider refactoring.
Open

    {
        /**
         * Initializes the source-adapter
         *
         * @method initialize
Severity: Minor
Found in lib/storageAdapter/keyValueStorageAdapter.js - About 3 hrs to fix

Function _prepareBucket has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        _prepareBucket: function (bucketName, key, initialValue, failWhenExist) {

            return this.getPromise().then(function () {

                return this._connection.hasBucket(bucketName).then(function (hasBucket) {
Severity: Minor
Found in lib/storageAdapter/keyValueStorageAdapter.js - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

        _prepareCompanyBucket: function () {
            var id = 'company_' + uuid.v4();
            return this._prepareBucket('companies', this._company, {
                id: id
            }).then(function () {
Severity: Major
Found in lib/storageAdapter/keyValueStorageAdapter.js and 2 other locations - About 4 hrs to fix
lib/storageAdapter/keyValueStorageAdapter.js on lines 120..129
lib/storageAdapter/keyValueStorageAdapter.js on lines 138..147

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

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

        _prepareDepartmentBucket: function () {
            var id = 'department_' + uuid.v4();
            return this._prepareBucket('departments', this._department, {
                id: id
            }).then(function () {
Severity: Major
Found in lib/storageAdapter/keyValueStorageAdapter.js and 2 other locations - About 4 hrs to fix
lib/storageAdapter/keyValueStorageAdapter.js on lines 102..111
lib/storageAdapter/keyValueStorageAdapter.js on lines 138..147

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

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

        _prepareProjectBucket: function () {
            var id = 'project_' + uuid.v4();
            return this._prepareBucket('projects', this._project, {
                id: id
            }).then(function () {
Severity: Major
Found in lib/storageAdapter/keyValueStorageAdapter.js and 2 other locations - About 4 hrs to fix
lib/storageAdapter/keyValueStorageAdapter.js on lines 102..111
lib/storageAdapter/keyValueStorageAdapter.js on lines 120..129

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

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

        archiveApprovedScreen: function (name, image) {
            return this.getPromise().then(function () {
                return this._blobImage(image);
            }.bind(this)).then(function (blob) {
                return this._connection.setObject(this._getApprovedScreenBucket(), name, blob, 'image/png');
Severity: Major
Found in lib/storageAdapter/keyValueStorageAdapter.js and 3 other locations - About 3 hrs to fix
lib/storageAdapter/keyValueStorageAdapter.js on lines 326..332
lib/storageAdapter/keyValueStorageAdapter.js on lines 414..420
lib/storageAdapter/keyValueStorageAdapter.js on lines 458..464

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

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

        archiveCurrentApprovedScreen: function (name, image) {
            return this.getPromise().then(function () {
                return this._blobImage(image);
            }.bind(this)).then(function (blob) {
                return this._connection.setObject(this._getCurrentApprovedScreenBucket(), name, blob, 'image/png');
Severity: Major
Found in lib/storageAdapter/keyValueStorageAdapter.js and 3 other locations - About 3 hrs to fix
lib/storageAdapter/keyValueStorageAdapter.js on lines 370..376
lib/storageAdapter/keyValueStorageAdapter.js on lines 414..420
lib/storageAdapter/keyValueStorageAdapter.js on lines 458..464

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

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

        archiveHighlightScreen: function (name, image) {
            return this.getPromise().then(function () {
                return this._blobImage(image);
            }.bind(this)).then(function (blob) {
                return this._connection.setObject(this._getHighlightScreenBucket(), name, blob, 'image/png');
Severity: Major
Found in lib/storageAdapter/keyValueStorageAdapter.js and 3 other locations - About 3 hrs to fix
lib/storageAdapter/keyValueStorageAdapter.js on lines 326..332
lib/storageAdapter/keyValueStorageAdapter.js on lines 370..376
lib/storageAdapter/keyValueStorageAdapter.js on lines 414..420

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

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

        archiveBuildScreen: function (name, image) {
            return this.getPromise().then(function () {
                return this._blobImage(image);
            }.bind(this)).then(function (blob) {
                return this._connection.setObject(this._getBuildScreenBucket(), name, blob, 'image/png');
Severity: Major
Found in lib/storageAdapter/keyValueStorageAdapter.js and 3 other locations - About 3 hrs to fix
lib/storageAdapter/keyValueStorageAdapter.js on lines 326..332
lib/storageAdapter/keyValueStorageAdapter.js on lines 370..376
lib/storageAdapter/keyValueStorageAdapter.js on lines 458..464

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

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

        getBuildScreen: function (name) {
            return this.getPromise().then(function () {
                return this._connection.getObject(this._getBuildScreenBucket(), name);
            }.bind(this)).then(function (blob) {
                return this._loadImage(blob);
Severity: Major
Found in lib/storageAdapter/keyValueStorageAdapter.js and 3 other locations - About 2 hrs to fix
lib/storageAdapter/keyValueStorageAdapter.js on lines 310..316
lib/storageAdapter/keyValueStorageAdapter.js on lines 354..360
lib/storageAdapter/keyValueStorageAdapter.js on lines 442..448

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

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

        getHighlightScreen: function (name) {
            return this.getPromise().then(function () {
                return this._connection.getObject(this._getHighlightScreenBucket(), name);
            }.bind(this)).then(function (blob) {
                return this._loadImage(blob);
Severity: Major
Found in lib/storageAdapter/keyValueStorageAdapter.js and 3 other locations - About 2 hrs to fix
lib/storageAdapter/keyValueStorageAdapter.js on lines 310..316
lib/storageAdapter/keyValueStorageAdapter.js on lines 354..360
lib/storageAdapter/keyValueStorageAdapter.js on lines 398..404

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

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

        getCurrentApprovedScreen: function (name) {
            return this.getPromise().then(function () {
                return this._connection.getObject(this._getCurrentApprovedScreenBucket(), name);
            }.bind(this)).then(function (blob) {
                return this._loadImage(blob);
Severity: Major
Found in lib/storageAdapter/keyValueStorageAdapter.js and 3 other locations - About 2 hrs to fix
lib/storageAdapter/keyValueStorageAdapter.js on lines 354..360
lib/storageAdapter/keyValueStorageAdapter.js on lines 398..404
lib/storageAdapter/keyValueStorageAdapter.js on lines 442..448

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

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

        getApprovedScreen: function (name) {
            return this.getPromise().then(function () {
                return this._connection.getObject(this._getApprovedScreenBucket(), name);
            }.bind(this)).then(function (blob) {
                return this._loadImage(blob);
Severity: Major
Found in lib/storageAdapter/keyValueStorageAdapter.js and 3 other locations - About 2 hrs to fix
lib/storageAdapter/keyValueStorageAdapter.js on lines 310..316
lib/storageAdapter/keyValueStorageAdapter.js on lines 398..404
lib/storageAdapter/keyValueStorageAdapter.js on lines 442..448

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

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

        getBuildScreenNames: function () {
            return this.getPromise().then(function () {
                return this._connection.getBucketKeys(this._getBuildScreenBucket());
            }.bind(this));
        },
Severity: Major
Found in lib/storageAdapter/keyValueStorageAdapter.js and 3 other locations - About 1 hr to fix
lib/storageAdapter/keyValueStorageAdapter.js on lines 297..301
lib/storageAdapter/keyValueStorageAdapter.js on lines 341..345
lib/storageAdapter/keyValueStorageAdapter.js on lines 429..433

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

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

        getCurrentApprovedScreenNames: function () {
            return this.getPromise().then(function () {
                return this._connection.getBucketKeys(this._getCurrentApprovedScreenBucket());
            }.bind(this));
        },
Severity: Major
Found in lib/storageAdapter/keyValueStorageAdapter.js and 3 other locations - About 1 hr to fix
lib/storageAdapter/keyValueStorageAdapter.js on lines 341..345
lib/storageAdapter/keyValueStorageAdapter.js on lines 385..389
lib/storageAdapter/keyValueStorageAdapter.js on lines 429..433

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

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

        getHighlightScreenNames: function () {
            return this.getPromise().then(function () {
                return this._connection.getBucketKeys(this._getHighlightScreenBucket());
            }.bind(this));
        },
Severity: Major
Found in lib/storageAdapter/keyValueStorageAdapter.js and 3 other locations - About 1 hr to fix
lib/storageAdapter/keyValueStorageAdapter.js on lines 297..301
lib/storageAdapter/keyValueStorageAdapter.js on lines 341..345
lib/storageAdapter/keyValueStorageAdapter.js on lines 385..389

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

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

        getApprovedScreenNames: function () {
            return this.getPromise().then(function () {
                return this._connection.getBucketKeys(this._getApprovedScreenBucket());
            }.bind(this));
        },
Severity: Major
Found in lib/storageAdapter/keyValueStorageAdapter.js and 3 other locations - About 1 hr to fix
lib/storageAdapter/keyValueStorageAdapter.js on lines 297..301
lib/storageAdapter/keyValueStorageAdapter.js on lines 385..389
lib/storageAdapter/keyValueStorageAdapter.js on lines 429..433

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

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