smartinmedia/cunity

View on GitHub

Showing 617 of 617 total issues

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

            function h(e, t, n, i, r, o) {
Severity: Minor
Found in lib/plugins/plupload/js/plupload.full.min.js - About 45 mins to fix

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

function refreshStatus() {
    for (var i in chatBoxes) {
        var data = $("#chat-panel-" + i).data("conversation"), userData = $("#chat-user-" + data.partners[0]).data("user");
        $("#chat-panel-" + data.conversation_id + " .panel-heading i.fa:first").removeClass("chat-panel-status-inactive chat-panel-status-active chat-panel-status-offline fa-circle-o fa-circle");
        if ((data.partners.length === 1 && typeof userData === "undefined") || (typeof userData === "undefined" || userData.online === 0))
Severity: Minor
Found in lib/modules/Messages/styles/javascript/chat.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

Avoid deeply nested control flow statements.
Open

                        if (opts.initSelection === undefined) {
                            opts.initSelection = function (element, callback) {
                                var data = [];
                                $(splitVal(element.val(), opts.separator, opts.transformVal)).each(function () {
                                    var obj = { id: this, text: this },
Severity: Major
Found in lib/plugins/select2/select2.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if (i === 3) {
                            userstring += ", +" + (us.length - 3);
                            break;
                        }
Severity: Major
Found in lib/modules/Messages/styles/javascript/inbox.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                                if (!(r = e.arrayIntersect(r, o)))return r = !1
Severity: Major
Found in lib/plugins/plupload/js/plupload.full.min.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if (opts.createSearchChoice === undefined) {
                            opts.createSearchChoice = function (term) { return {id: $.trim(term), text: $.trim(term)}; };
                        }
Severity: Major
Found in lib/plugins/select2/select2.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                                                        if (this.viewMode === 1)
                                                            this._trigger('changeYear', this.viewDate);
Severity: Major
Found in lib/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                                                if (this.o.minViewMode === 1) {
                                                    this._setDate(UTCDate(year, month, day));
                                                }
Severity: Major
Found in lib/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js - About 45 mins to fix

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

    public function loadOnlineFriends($userid)
    {
        $friendlist = $this->getAdapter()->fetchAll($this->getAdapter()->select()->from(['u' => $this->_dbprefix.'users'])
            ->joinLeft(['pi' => $this->_dbprefix.'gallery_images'], 'pi.id = u.profileImage', 'filename AS pimg')
            ->where('u.userid IN ('.new \Zend_Db_Expr($this->getAdapter()->select()
Severity: Minor
Found in lib/modules/Friends/Models/Db/Table/Relationships.php - 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 loadAlbum has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private function loadAlbum()
    {
        $albums = new GalleryAlbums();
        $album = $albums->getAlbumData(Get::get('action'));
        if ($album !== false) {
Severity: Minor
Found in lib/modules/Gallery/Models/Process.php - 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 initTranslator has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private function initTranslator()
    {
        if (Get::get('lang') !== null && (file_exists('installer/lang/'.Get::get('lang').'.php') || Get::get('lang') == 'en')) {
            self::$lang = Get::get('lang');
            Session::set('lang', self::$lang);
Severity: Minor
Found in installer/Install.php - 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

Method resize has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    abstract public function resize($width,
                                    $height,
                                    $keepRatio,
                                    $file,
                                    $target,
Severity: Minor
Found in lib/Skoch/Filter/File/Adapter/AbstractAdapter.php - About 45 mins to fix

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

    public function isValid($value)
    {
        $returnValue = false;

        $this->_setValue($value);
Severity: Minor
Found in lib/modules/Core/Models/Validation/Email.php - 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 deleteImage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function deleteImage()
    {
        if ($this->owner_id == Session::get('user')->userid && $this->owner_type === null) {
            $albums = new GalleryAlbums();
            $album = $albums->find($this->albumid);
Severity: Minor
Found in lib/modules/Gallery/Models/Db/Row/Image.php - 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 loadData has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    protected function loadData()
    {
        $statisticData = [];
        $statistics = new \Cunity\Admin\Models\Db\Table\Statistics();
        $data = $statistics->getLastMonths();
Severity: Minor
Found in lib/modules/Admin/Models/Pages/Statistics.php - 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 getPrivacy has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function getPrivacy($type = false, $userid = 0)
    {
        if ($userid == 0) {
            $userid = Session::get('user')->userid;
        }
Severity: Minor
Found in lib/modules/Profile/Models/Db/Table/Privacy.php - 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

Method resize has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function resize($width,
                           $height,
                           $keepRatio,
                           $file,
                           $target,
Severity: Minor
Found in lib/Skoch/Filter/File/Adapter/Gd.php - About 45 mins to fix

Method calculateMetrics has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    private function calculateMetrics($width, $height, $keepRatio, $keepSmaller, $oldWidth, $oldHeight)
Severity: Minor
Found in lib/Skoch/Filter/File/Adapter/Gd.php - About 45 mins to fix

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

    $("#thread-new-emoticon-button").popover({
        html: true,
        container: 'body',
        content: function () {
            return $("#thread-new-emoticons > div").html();
Severity: Major
Found in lib/modules/Forums/styles/javascript/board.js and 2 other locations - About 45 mins to fix
lib/modules/Forums/styles/javascript/thread.js on lines 14..20
lib/modules/Messages/styles/javascript/conversation.js on lines 75..81

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

    for (x in smileys)
        res.data.message = res.data.message.replace('[:' + x + ':]', smileys[x]);
Severity: Minor
Found in lib/modules/Messages/styles/javascript/conversation.js and 1 other location - About 45 mins to fix
lib/modules/Messages/styles/javascript/chat.js on lines 151..152

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

Severity
Category
Status
Source
Language