PlanHubMe/PlanHub

View on GitHub

Showing 857 of 857 total issues

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

        $response.find(".eventlist")
                    .children(".event").each(function() {
                        // !!!
                        var eventTitle = $(this).children(".referer").children("a").text().replace(/\s{2,}/g, " ");
                        if ($(this).children(".referer").length == 0) {
Severity: Major
Found in public/js/coursesLib.js and 1 other location - About 1 day to fix
public/js/coursesLib.js on lines 106..122

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

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

        $response.find(".eventlist")
                    .children(".event").each(function() {
                        // !!!
                        var eventTitle = $(this).children(".referer").children("a").text().replace(/\s{2,}/g, " ");
                        if ($(this).children(".referer").length == 0) {
Severity: Major
Found in public/js/coursesLib.js and 1 other location - About 1 day to fix
public/js/coursesLib.js on lines 77..93

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

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

router.get('/announcements/get/:date', global.apiCall, function(req, res, next) {
    if (req.params.date === undefined) {
        res.json({
            status: "error",
            error: "Missing or invalid date parameter!"
Severity: Major
Found in routes/api_planner.js and 1 other location - About 1 day to fix
routes/api_planner.js on lines 66..91

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

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

router.get('/fridays/get/:date', global.apiCall, function(req, res, next) {
    if (req.params.date === undefined) {
        res.json({
            status: "error",
            error: "Missing or invalid date parameter!"
Severity: Major
Found in routes/api_planner.js and 1 other location - About 1 day to fix
routes/api_planner.js on lines 11..36

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

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

window.planner.createSubjectRow = function(subjectName, subjectIndex) {
    var $row = $('<tr class="subjectRow"></tr>');
        $row.attr("data-subjectName", subjectName);
        $row.attr("data-subjectIndex", subjectIndex);

Severity: Major
Found in public/js/planner.js - About 1 day to fix

    File planner.js has 504 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    window.planner = {
        currentStartDate: null,
        loadState: 0,
        subjectCount: 0,
        saving: false,
    Severity: Major
    Found in public/js/planner.js - About 1 day to fix

      File api_planner.js has 488 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      var express = require('express');
      var router = express.Router();
      
      router.get('/', global.apiCall, function(req, res, next) {
          res.json({
      Severity: Minor
      Found in routes/api_planner.js - About 7 hrs to fix

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

            global.knex("users").select("*").where({ username: req.session.username }).then(function(obj) {
                if (obj.length > 1) {
                    res.render("error", { title: "Error", msg: "A database error has occurred, and there is a duplicate user record. Please contact us for assistance." });
                    return;
                }
        Severity: Major
        Found in app.js and 1 other location - About 6 hrs to fix
        app.js on lines 146..157

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

        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

            global.knex("users").select("*").where({ username: req.session.username }).then(function(obj) {
                if (obj.length > 1) {
                    res.render("error", { title: "Error", msg: "A database error has occurred, and there is a duplicate user record. Please contact us for assistance." });
                    return;
                }
        Severity: Major
        Found in app.js and 1 other location - About 6 hrs to fix
        app.js on lines 68..79

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

        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

        router.get('/errors/get/:id', global.apiCall, global.requireUser, global.getUserRecord, global.requireViewFeedback, function(req, res, next) {
            knex("errors").where({
                errorId: req.params.id
            }).select("*").then(function(obj) {
                res.json({
        Severity: Major
        Found in routes/api_admin.js and 1 other location - About 5 hrs to fix
        routes/api_admin.js on lines 41..55

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

        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

        router.get('/feedback/get/:id', global.apiCall, global.requireUser, global.getUserRecord, global.requireViewFeedback, function(req, res, next) {
            knex("feedback").where({
                feedbackId: req.params.id
            }).select("*").then(function(obj) {
                res.json({
        Severity: Major
        Found in routes/api_admin.js and 1 other location - About 5 hrs to fix
        routes/api_admin.js on lines 73..87

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

        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 context has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
        Open

        var context = context || (function () {
            
            var options = {
                fadeSpeed: 100,
                filter: function ($obj) {
        Severity: Minor
        Found in public/js/context.js - About 5 hrs 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 loadWholeWeek has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
        Open

        window.planner.loadWholeWeek = function(startDate, subjectIndex) {
            window.api.get("planner/events/getWholeWeek/" + window.utils.formatDate_api(startDate), function(data) {
                for (var announcementIndex in data.announcements) {
                    var announcement = data.announcements[announcementIndex];
                    var date = announcement.date.split("T")[0];
        Severity: Minor
        Found in public/js/planner.js - About 4 hrs 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 context has 116 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var context = context || (function () {
            
            var options = {
                fadeSpeed: 100,
                filter: function ($obj) {
        Severity: Major
        Found in public/js/context.js - About 4 hrs to fix

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

          global.requireViewFeedback = function(req, res, next) {
              if (res.locals.user.canFeedback != 1) {
                  if (res.locals.apiCall) {
                      res.json({
                          status: "forbidden",
          Severity: Major
          Found in app.js and 2 other locations - About 3 hrs to fix
          app.js on lines 84..97
          app.js on lines 114..127

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

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

          global.requireNonZeroLevel = function(req, res, next) {
              if (res.locals.user.level < 0) {
                  if (res.locals.apiCall) {
                      res.json({
                          status: "forbidden",
          Severity: Major
          Found in app.js and 2 other locations - About 3 hrs to fix
          app.js on lines 99..112
          app.js on lines 114..127

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

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

          global.requireEditAnnouncements = function(req, res, next) {
              if (res.locals.user.canAnnouncements != 1) {
                  if (res.locals.apiCall) {
                      res.json({
                          status: "forbidden",
          Severity: Major
          Found in app.js and 2 other locations - About 3 hrs to fix
          app.js on lines 84..97
          app.js on lines 99..112

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

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

          window.hwView.addEventToList = function(ev, list) {
              var tag = window.utils.getPrefix(ev.name);
              var name = ev.name.split(" ");
              name.splice(0, 1);
              name = name.join(" ");
          Severity: Major
          Found in public/js/hwView.js - About 3 hrs to fix

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

                                $titleWord.change(function() {
                                    $(this).parent().attr("id", $(this).val());
                                    var setList = JSON.stringify($("#title-sorting").sortable("toArray"));
                                    window.api.post("prefs/set", {name: "titleOrder", value:setList}, function() {});
                                });
            Severity: Major
            Found in public/js/prefs.js and 1 other location - About 3 hrs to fix
            public/js/prefs.js on lines 98..102

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

            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

                            $inputBox.change(function(){
                                $(this).parent().attr("id", $(this).val());
                                var setList = JSON.stringify($("#title-sorting").sortable("toArray"));
                                window.api.post("prefs/set", {name: "titleOrder", value:setList}, function() {});
                            });
            Severity: Major
            Found in public/js/prefs.js and 1 other location - About 3 hrs to fix
            public/js/prefs.js on lines 122..126

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

            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