smartinmedia/cunity

View on GitHub
lib/modules/Newsfeed/styles/javascript/newsfeed.js

Summary

Maintainability
F
3 days
Test Coverage

File newsfeed.js has 334 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var offset = 0, postLoad = 20, globeFilter, uploader = null;
$(document).ready(function () {
    load(false);
    $('#postmsg').keyup(function() {
        if ($('#postmsg').val() != '') {
Severity: Minor
Found in lib/modules/Newsfeed/styles/javascript/newsfeed.js - About 4 hrs 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 load has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function load(refresh, filter) {
    $("#newsfeed-posts > .alert-danger").hide();
    refreshId = 0;
    if (refresh) {
        refreshId = $("#newsfeed-posts > .newsfeed-post:first").data("id");
Severity: Minor
Found in lib/modules/Newsfeed/styles/javascript/newsfeed.js - About 1 hr to fix

Function loadSinglePost has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function loadSinglePost(postid) {
    sendRequest({"postid": postid}, "newsfeed", "loadPost", function (res) {
        if ((typeof res.likes === "undefined" || res.likes.length === 0) && (typeof res.dislikes === "undefined" || res.dislikes.length === 0))
            $("#post-" + postid + " .newsfeed-post-detail-likebox").hide();
        else
Severity: Minor
Found in lib/modules/Newsfeed/styles/javascript/newsfeed.js - About 1 hr to fix

Function success has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        success: function () {
            uploader = new plupload.Uploader({
                runtimes: 'html5,flash,silverlight,html4',
                browse_button: 'newsfeed-upload',
                multi_selection: false,
Severity: Minor
Found in lib/modules/Newsfeed/styles/javascript/newsfeed.js - About 1 hr to fix

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

    $(document).on("click", ".newsfeed-post-area,.newsfeed-post-option", function () {
        $(".newsfeed-post-option").hide();
        $(".newsfeed-post-option-buttons").show();
        $(".newsfeed-post-area > textarea").outerHeight(250).focus();
        $(".newsfeed-post-buttons").show();
Severity: Major
Found in lib/modules/Newsfeed/styles/javascript/newsfeed.js and 1 other location - About 1 day to fix
lib/modules/Newsfeed/styles/javascript/newsfeed.js on lines 17..45

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

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

        if (typeof res.likes !== "undefined" && res.likes.length > 0) {
            $("#likes-" + postid + " > span.label").hide();
            for (x in res.likes) {
                if (x == 5)
                    break;
Severity: Major
Found in lib/modules/Newsfeed/styles/javascript/newsfeed.js and 1 other location - About 5 hrs to fix
lib/modules/Newsfeed/styles/javascript/newsfeed.js on lines 155..164

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

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

        if (typeof res.dislikes !== "undefined" && res.dislikes.length > 0) {
            $("#dislikes-" + postid + " > span.label").hide();
            for (x in res.dislikes) {
                if (x == 5)
                    break;
Severity: Major
Found in lib/modules/Newsfeed/styles/javascript/newsfeed.js and 1 other location - About 5 hrs to fix
lib/modules/Newsfeed/styles/javascript/newsfeed.js on lines 146..154

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

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

                if (res.posts.length < postLoad)
                    $(".newsfeed-postbox-load-more").hide();
                else
                    $(".newsfeed-postbox-load-more").show();
Severity: Minor
Found in lib/modules/Newsfeed/styles/javascript/newsfeed.js and 1 other location - About 30 mins to fix
lib/modules/Gallery/styles/javascript/album.js on lines 71..74

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

There are no issues that match your filters.

Category
Status