Asymmetrik/mean2-starter

View on GitHub

Showing 230 of 230 total issues

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

                auditService.audit('user update authentication failed', 'user', 'update authentication failed',
                    User.auditCopy(req.user, util.getHeaderField(req.headers, 'x-real-ip')), {}, req.headers);
src/server/app/admin/controllers/users/eua.server.controller.js on lines 97..98

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

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

exports.search = function(req, res) {
    let search = req.body.s || null;
    let query = req.body.q || {};
    query = util.toMongoose(query);

Severity: Minor
Found in src/server/app/audit/controllers/audit.server.controller.js - About 25 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 validatePassword has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public validatePassword(p1: string, p2: string): any {
        p1 = (_.isString(p1) && p1.trim().length > 0) ? p1 : undefined;
        p2 = (_.isString(p2) && p2.trim().length > 0) ? p2 : undefined;

        if (p1 !== p2) {
Severity: Minor
Found in src/client/app/admin/authentication/authentication.service.ts - About 25 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 ignorePayload has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

KafkaSocket.prototype.ignorePayload = function(rawMessage, json, consumer) {
    // Ignore any payloads that are too old.
    if (null != ignoreOlderThan) {
        var now = Date.now();
        var messageTime = this.getMessageTime(json);
Severity: Minor
Found in src/server/app/util/sockets/kafka.server.socket.js - About 25 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 a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

module.exports.containsQuery = function(schema, query, fields, search, limit, offset, sortArr, runCount) {
    // Initialize find to null
    var find = generateFind(query);
    var projection = {};
    var options = {};
Severity: Minor
Found in src/server/app/util/services/query.server.service.js - About 25 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 requiresRole has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

module.exports.requiresRole = function(role) {
    return function(req) {

        // Verify that the user and tag are on the request
        let user = req.user.toObject();
Severity: Minor
Found in src/server/app/teams/controllers/tags.server.controller.js - About 25 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 getConsumer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

KafkaConsumer.prototype.getConsumer = function() {
    let self = this;

    // Initialize the deferred promise, if we don't already have one.
    self.deferred = self.deferred || q.defer();
Severity: Minor
Found in src/server/lib/kafka-consumer.js - About 25 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 ignorePayload has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

EventSocket.prototype.ignorePayload = function(json) {
    // Ignore any payloads that are too old.
    if (null != ignoreOlderThan) {
        var now = Date.now();
        var messageTime = this.getMessageTime(json);
Severity: Minor
Found in src/server/app/util/sockets/event.server.socket.js - About 25 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

TODO found
Open

    user.username = dn; //TODO: extract the username

TODO found
Open

    <!-- TODO: When forking the starter and enabling notifications, you must provide an implementation of a notification viewer and configure the route -->
Severity
Category
Status
Source
Language