Asymmetrik/mean2-starter

View on GitHub

Showing 230 of 230 total issues

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

EventSocket.prototype.disconnect = function() {
    logger.info('%s: Disconnected from client.', this.name);
    this.unsubscribe(null);
};
Severity: Minor
Found in src/server/app/util/sockets/event.server.socket.js and 1 other location - About 50 mins to fix
src/server/app/util/sockets/kafka.server.socket.js on lines 59..62

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

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

KafkaSocket.prototype.disconnect = function() {
    logger.info('%s: Disconnected from client.', this.name);
    this.unsubscribe(null);
};
Severity: Minor
Found in src/server/app/util/sockets/kafka.server.socket.js and 1 other location - About 50 mins to fix
src/server/app/util/sockets/event.server.socket.js on lines 30..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 51.

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

Function search has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

module.exports.search = function(query, queryParams, user) {
    if (!user || !user._id) {
        return q.reject('Notification Service: user._id must be defined');
    }

Severity: Minor
Found in src/server/app/notifications/services/notification.server.service.js - About 45 mins 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

Function getQuery has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private getQuery(): any {
        let query: any;
        let elements: any[] = [];

        if (this.filters.bypassAC) {
Severity: Minor
Found in src/client/app/admin/user-management/admin-list-users.component.ts - About 45 mins 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

Function transform has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    transform(n: number): string {
        let scale: any = this.getScale(n);
        let postfix: string = '';
        let fraction: number = n;
        let fractionSize: number;
Severity: Minor
Found in src/client/app/shared/big-number.pipe.ts - About 45 mins 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

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

UserSchema.statics.containsQuery = function(queryTerms, fields, search, limit, offset, sortArr) {
Severity: Minor
Found in src/server/app/admin/models/user.server.model.js - About 45 mins to fix

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

    module.exports.audit = function(message, eventType, eventAction, eventActor, eventObject, eventMetadata) {
    Severity: Minor
    Found in src/server/app/audit/services/audit.server.service.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                                      for (let partition in offsets[topic]) {
                                          offsets[topic][partition] = Math.min.apply(null, offsets[topic][partition]);
                                          logger.info(`Kafka Consumer: Connected to topic ${topic}, partition: ${partition}, offset: ${offsets[topic][partition]}`);
                                      }
      Severity: Major
      Found in src/server/lib/kafka-consumer.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                for (let i in excludes) {
                                    file = file.replace(excludes[i], '');
                                }
        Severity: Major
        Found in src/server/config.js - About 45 mins to fix

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

          CacheEntrySchema.statics.containsQuery = function(queryTerms, fields, search, limit, offset, sortArr) {
          Severity: Minor
          Found in src/server/app/access-checker/models/cache-entry.server.model.js - About 45 mins to fix

            Function requiresExternalRoles has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            module.exports.requiresExternalRoles = (req) => {
                let promise;
            
                // If there are required roles, check for them
                if(req.user.bypassAccessCheck === false && null != config.auth && _.isArray(config.auth.requiredRoles) && config.auth.requiredRoles.length > 0) {

            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

            Function getGlobbedPaths has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            let getGlobbedPaths = (globPatterns, excludes) => {
                // URL paths regex
                let urlRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
            
                // The output array
            Severity: Minor
            Found in src/server/config.js - About 45 mins 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

            Function itemsRaw has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                set itemsRaw(newValue: string) {
                    if (newValue) {
                        let split = new RegExp(this.delimiter, 'g');
                        this._items = _.map(newValue.match(split), (val: string) => {
                            if (
            Severity: Minor
            Found in src/client/app/shared/list-manager.component.ts - About 45 mins 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

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

                                    teamIds = teamIds.map((teamId) => {
                                        if (_.isString(teamId)) {
                                            return mongoose.Types.ObjectId(teamId);
                                        }
                                    });
            Severity: Minor
            Found in src/server/app/resources/services/resources.server.service.js and 1 other location - About 45 mins to fix
            src/server/app/resources/services/resources.server.service.js on lines 149..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 50.

            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

                                        teamIds = teamIds.map((teamId) => {
                                            if (_.isString(teamId)) {
                                                return mongoose.Types.ObjectId(teamId);
                                            }
                                        });
            Severity: Minor
            Found in src/server/app/resources/services/resources.server.service.js and 1 other location - About 45 mins to fix
            src/server/app/resources/services/resources.server.service.js on lines 101..105

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

            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

                retrySend().then(getProducer).then((producer) => {
            
                    // Send the payload to Kafka.
                    let d = q.defer();
                    producer.send(payloads, d.makeNodeResolver());
            Severity: Minor
            Found in src/server/lib/kafka-producer.js and 1 other location - About 45 mins to fix
            src/server/lib/kafka-producer.js on lines 163..170

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

            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

                getProducer().then((producer) => {
            
                    // Send the payload to Kafka
                    let d = q.defer();
                    producer.send(_retryPayloads, d.makeNodeResolver());
            Severity: Minor
            Found in src/server/lib/kafka-producer.js and 1 other location - About 45 mins to fix
            src/server/lib/kafka-producer.js on lines 117..124

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

            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

            module.exports.read = function(req, res) {
                res.status(200).json(req.tag);
            };
            Severity: Minor
            Found in src/server/app/teams/controllers/tags.server.controller.js and 1 other location - About 40 mins to fix
            src/server/app/teams/controllers/teams.server.controller.js on lines 32..34

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

            module.exports.read = function(req, res) {
                res.status(200).json(req.team);
            };
            Severity: Minor
            Found in src/server/app/teams/controllers/teams.server.controller.js and 1 other location - About 40 mins to fix
            src/server/app/teams/controllers/tags.server.controller.js on lines 32..34

            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

            Consider simplifying this complex logical expression.
            Open

                            if (
                                (val.charAt(0) === '"' || val.charAt(0) === '\'' || val.charAt(0) === '“') &&
                                (val.charAt(val.length - 1) === '"' || val.charAt(val.length - 1) === '\'' || val.charAt(val.length - 1) === '”')) {
            
                                val = val.substring(1, val.length - 1);
            Severity: Major
            Found in src/client/app/shared/list-manager.component.ts - About 40 mins to fix
              Severity
              Category
              Status
              Source
              Language