smartinmedia/cunity

View on GitHub

Showing 617 of 617 total issues

File profile-edit.js has 251 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var uploader = null;
$(document).ready(function () {
    $(".datepicker").datepicker();

    $('form input, form select').change(function() {
Severity: Minor
Found in lib/modules/Profile/styles/javascript/profile-edit.js - About 2 hrs to fix

Function update has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

                        update: function() {
                            if (!this._allow_update)
                                return;

                            var oldDates = this.dates.copy(),
Severity: Minor
Found in lib/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js - About 2 hrs to fix

Consider simplifying this complex logical expression.
Open

                    if ($guest['status'] == 0 && (($limit > 0 && count($guests['invited']) < $limit) || $limit == 0)) {
                        $guests['invited'][] = $guest;
                    } elseif ($guest['status'] == 1 && (($limit > 0 && count($guests['maybe']) < $limit) || $limit == 0)) {
                        $guests['maybe'][] = $guest;
                    } elseif ($guest['status'] == 2 && (($limit > 0 && count($guests['attending']) < $limit) || $limit == 0)) {
Severity: Critical
Found in lib/modules/Events/Models/Db/Table/Guests.php - About 2 hrs to fix

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

function update() {
    var status = false;
    sendRequest({action: "save", form: "update"}, "admin", "save", function (res) {
        status = res.status;

Severity: Major
Found in lib/modules/Admin/styles/update/javascript/update.js and 1 other location - About 2 hrs to fix
lib/modules/Admin/styles/filesharing/javascript/filesharing.js on lines 8..19

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

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 (!(d.length > 1 || e && 1 !== e))if (this.options.disableScroll && a.preventDefault(), this.touchDelta = {
                    x: d.pageX - this.touchStart.x,
                    y: d.pageY - this.touchStart.y
                }, b = this.touchDelta.x, void 0 === this.isScrolling && (this.isScrolling = this.isScrolling || Math.abs(b) < Math.abs(this.touchDelta.y)), this.isScrolling)this.options.closeOnSwipeUpOrDown && this.translateY(f, this.touchDelta.y + this.positions[f], 0); else for (a.preventDefault(), window.clearTimeout(this.timeout), this.options.continuous ? c = [this.circle(f + 1), f, this.circle(f - 1)] : (this.touchDelta.x = b /= !f && b > 0 || f === this.num - 1 && 0 > b ? Math.abs(b) / this.slideWidth + 1 : 1, c = [f], f && c.push(f - 1), f < this.num - 1 && c.unshift(f + 1)); c.length;)f = c.pop(), this.translateX(f, b + this.positions[f], 0)
Severity: Critical
Found in lib/modules/Gallery/styles/javascript/jquery.blueimp-gallery.min.js - About 2 hrs to fix

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

function update() {
    var status = false;
    sendRequest({action: "save", form: "update"}, "admin", "save", function (res) {
        status = res.status;

lib/modules/Admin/styles/update/javascript/update.js on lines 8..19

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

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 (!(d.length > 1 || e && 1 !== e))if (this.options.disableScroll && a.preventDefault(), this.touchDelta = {
                    x: d.pageX - this.touchStart.x,
                    y: d.pageY - this.touchStart.y
                }, b = this.touchDelta.x, void 0 === this.isScrolling && (this.isScrolling = this.isScrolling || Math.abs(b) < Math.abs(this.touchDelta.y)), this.isScrolling)this.options.closeOnSwipeUpOrDown && this.translateY(f, this.touchDelta.y + this.positions[f], 0); else for (a.preventDefault(), window.clearTimeout(this.timeout), this.options.continuous ? c = [this.circle(f + 1), f, this.circle(f - 1)] : (this.touchDelta.x = b /= !f && b > 0 || f === this.num - 1 && 0 > b ? Math.abs(b) / this.slideWidth + 1 : 1, c = [f], f && c.push(f - 1), f < this.num - 1 && c.unshift(f + 1)); c.length;)f = c.pop(), this.translateX(f, b + this.positions[f], 0)
Severity: Critical
Found in lib/modules/Gallery/styles/javascript/blueimp-gallery.min.js - About 2 hrs to fix

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

        handleSlide: function (a) {
            this.options.continuous || this.updateEdgeClasses(a), this.loadElements(a), this.options.unloadElements && this.unloadElements(a), this.setTitle(a)
        },
Severity: Major
Found in lib/modules/Gallery/styles/javascript/blueimp-gallery.min.js and 1 other location - About 2 hrs to fix
lib/modules/Gallery/styles/javascript/jquery.blueimp-gallery.min.js on lines 267..269

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

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

        handleSlide: function (a) {
            this.options.continuous || this.updateEdgeClasses(a), this.loadElements(a), this.options.unloadElements && this.unloadElements(a), this.setTitle(a)
        },
lib/modules/Gallery/styles/javascript/blueimp-gallery.min.js on lines 319..321

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

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 N has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        function N(e, n, r) {
            function f(e, t, n) {
                var r = a[e];
                switch (e) {
                    case"max_file_size":
Severity: Minor
Found in lib/plugins/plupload/js/plupload.full.min.js - About 1 hr to fix

Function ajax has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function ajax(options) {
        var timeout, // current scheduled but not yet executed request
            handler = null,
            quietMillis = options.quietMillis || 100,
            ajaxUrl = options.url,
Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

Function postImage has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function postImage() {
    $(".newsfeed-post-file-input > .loader-small").show();
    $.ajax({
        url: siteurl + "lib/plugins/plupload/js/plupload.full.min.js",
        dataType: "script",
Severity: Minor
Found in lib/modules/Newsfeed/styles/javascript/newsfeed.js - About 1 hr to fix

Function fillModal has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function fillModal(res, el) {
    currentImgId = res.id;
    if (res.caption.length > 0)
        el.find(".imagetitle").html(res.caption).show();
    else
Severity: Minor
Found in lib/modules/Gallery/styles/javascript/lightbox.js - About 1 hr to fix

Function local has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function local(options) {
        var data = options, // data elements
            dataText,
            tmp,
            text = function (item) { return ""+item.text; }; // function used to retrieve the text portion of a data item that is matched against the search
Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

Function r has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        function r(t) {
            var r = this, s = n.capTest, u = n.capTrue;
            n.call(this, t, o, {
                access_binary: s(window.FileReader || window.File && File.getAsDataURL),
                access_image_binary: !1,
Severity: Minor
Found in lib/plugins/plupload/js/plupload.full.min.js - About 1 hr to fix

Function convertUrl has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

function convertUrl(data) {
    if (modrewrite) {
        var str = siteurl + data.module;
        if (typeof data.action !== "undefined" && data.action !== null)
            str += "/" + data.action;
Severity: Minor
Found in lib/modules/Core/styles/javascript/cunity-core.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

Function notify has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public static function notify($receiver, $sender, $type, $target, $ways = ['alert', 'mail'])
    {
        if (is_array($receiver)) {
            foreach ($receiver as $user) {
                self::notify($user['userid'], $sender, $type, $target, $ways);
Severity: Minor
Found in lib/modules/Notifications/Models/Notifier.php - 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

Function save has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private function save($form)
    {
        $res = [];
        switch ($form) {
            case 'settings':
Severity: Minor
Found in lib/modules/Admin/Models/Process.php - 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 4 locations. Consider refactoring.
Open

                                    else if (e.shiftKey) {
                                        newDate = this.moveMonth(this.dates.get(-1) || UTCToday(), dir);
                                        newViewDate = this.moveMonth(focusDate, dir);
                                        this._trigger('changeMonth', this.viewDate);
                                    }
lib/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js on lines 1107..1122
lib/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js on lines 1135..1150
lib/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js on lines 1140..1150

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

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

                                    else if (e.shiftKey) {
                                        newDate = this.moveMonth(this.dates.get(-1) || UTCToday(), dir);
                                        newViewDate = this.moveMonth(focusDate, dir);
                                        this._trigger('changeMonth', this.viewDate);
                                    }
lib/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js on lines 1107..1122
lib/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js on lines 1112..1122
lib/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js on lines 1135..1150

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

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

Severity
Category
Status
Source
Language