smartinmedia/cunity

View on GitHub

Showing 617 of 617 total issues

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

            switch (o.minViewMode) {
                case 1:
                case 'months':
                    o.minViewMode = 1;
                    break;
Severity: Major
Found in lib/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js and 1 other location - About 1 hr to fix
lib/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js on lines 161..172

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

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

                    $.fn.datepicker = function(option) {
                        var args = Array.apply(null, arguments);
                        args.shift();
                        var internal_return;
                        this.each(function() {
Severity: Minor
Found in lib/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js - About 1 hr to fix

Function i has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        function i(i) {
            function r() {
                var e, t;
                return e = a.call(this, 8), "IHDR" == e.type ? (t = e.start, {
                    width: u.LONG(t),
Severity: Minor
Found in lib/plugins/plupload/js/plupload.full.min.js - About 1 hr to fix

Function t has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        return function t(n) {
            var i = [], r, o, a, s = 0;
            if (r = new e, r.init(n), 65496 === r.SHORT(0)) {
                for (o = 2; o <= n.length;)if (a = r.SHORT(o), a >= 65488 && 65495 >= a)o += 2; else {
                    if (65498 === a || 65497 === a)break;
Severity: Minor
Found in lib/plugins/plupload/js/plupload.full.min.js - About 1 hr to fix

Method getNewsfeed has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getNewsfeed($offset, $refresh = 0, $filter = [])
    {
        $subquery = new \Zend_Db_Expr($this->select()->from($this, 'wall_id')->where('(owner_id IN ('.$this->friendslistQuery.") OR owner_id = ?) AND owner_type = 'profile'", Session::get('user')->userid)
            ->orWhere("owner_type = 'event' AND owner_id IN (".$this->eventslistQuery.')'));
        $query = $this->getAdapter()->select()->from(['p' => $this->_dbprefix.'posts'])
Severity: Minor
Found in lib/modules/Newsfeed/Models/Db/Table/Walls.php - About 1 hr to fix

Function registerCunityPlugin has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    protected function registerCunityPlugin($pluginName, array $files)
    {
        if (file_exists('plugins/'.$pluginName)) {
            if (!empty($files)) {
                foreach ($files as $file) {
Severity: Minor
Found in lib/modules/Core/View/View.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 defaultTokenizer has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function defaultTokenizer(input, selection, selectCallback, opts) {
        var original = input, // store the original so we can compare and know if we need to tell the search to update its text
            dupe = false, // check for whether a token we extracted represents a duplicate selected choice
            token, // token
            index, // position at which the separator was found
Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

Function DOMException has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

            }(), DOMException: function () {
                function n(e) {
                    this.code = e, this.name = t(i, e), this.message = this.name + ": DOMException " + this.code
                }

Severity: Minor
Found in lib/plugins/plupload/js/plupload.full.min.js - About 1 hr to fix

Function i has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

            function i(e, n) {
                var i = a.SHORT(e), r, o, s, u, d, f, p, h, m = [], g = {};
                for (r = 0; i > r; r++)if (p = f = e + 12 * r + 2, s = n[a.SHORT(p)], s !== t) {
                    switch (u = a.SHORT(p += 2), d = a.LONG(p += 2), p += 4, m = [], u) {
                        case 1:
Severity: Minor
Found in lib/plugins/plupload/js/plupload.full.min.js - About 1 hr to fix

Method handleRequest has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function handleRequest()
    {
        $view = new View(true);
        switch (Post::get('action')) {
            case 'loadMenu':
Severity: Minor
Found in lib/modules/Admin/Models/Pages/Appearance.php - About 1 hr to fix

Method get has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function get($userid, $key = 'userid')
    {
        $settings = Cunity::get('settings');

        if ($settings->getSetting('register.allfriends')) {
Severity: Minor
Found in lib/modules/Core/Models/Db/Table/Users.php - About 1 hr to fix

Function i has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        function i(o, a) {
            function s(t, n, o) {
                var a, s = r[this.uid];
                return "string" === e.typeOf(s) && s.length ? (a = new i(null, {
                    type: o,
Severity: Minor
Found in lib/plugins/plupload/js/plupload.full.min.js - About 1 hr to fix

Function onSelect has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        onSelect: function (data, options) {

            if (!this.triggerSelect(data) || data.text === "") { return; }

            this.addSelectedChoice(data);
Severity: Minor
Found in lib/plugins/select2/select2.js - About 1 hr to fix

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

                function r(r) {
                    k.bind("LoadStart", function (e) {
                        n("readyState", p.LOADING), s.dispatchEvent("readystatechange"), s.dispatchEvent(e), I && s.upload.dispatchEvent(e)
                    }), k.bind("Progress", function (e) {
                        n("readyState") !== p.LOADING && (n("readyState", p.LOADING), s.dispatchEvent("readystatechange")), s.dispatchEvent(e)
Severity: Minor
Found in lib/plugins/plupload/js/plupload.full.min.js - About 1 hr to fix

Method registerScript has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function registerScript($module, $scriptName)
    {
        if ((!empty($module))) {
            $module = ucfirst($module).'/styles/javascript/';
        } else {
Severity: Minor
Found in lib/modules/Core/View/View.php - About 1 hr to fix

Method loadAlbums has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function loadAlbums($userid)
    {
        $settings = Cunity::get('settings');

        if ($userid == 0) {
Severity: Minor
Found in lib/modules/Gallery/Models/Db/Table/GalleryAlbums.php - About 1 hr to fix

Function showCalendar has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function showCalendar() {
    if (window.innerWidth < 768)
        calendarview = "list";
    if (calendarview == "calendar") {
        if (calendar == null) {
Severity: Minor
Found in lib/modules/Events/styles/javascript/events.js - About 1 hr to fix

Function chatHearthBeat has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function chatHearthBeat() {
    if (chatStatus) {
        sendRequest({"chatboxes": chatBoxes}, "messages", "chatHearthBeat", function (data) {
            toggleChat(typeof data.msg === "undefined");
            if (data.users.length > 0) {
Severity: Minor
Found in lib/modules/Messages/styles/javascript/chat.js - About 1 hr to fix

Method startThread has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function startThread()
    {
        $threads = new Threads();
        $posts = new Posts();
        $category = Post::get('category');
Severity: Minor
Found in lib/modules/Forums/Models/Process.php - About 1 hr to fix

Method getLastMonths has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getLastMonths($numberOfMonths = 12)
    {
        $statistics = [];
        $date = new \DateTime();
        $startDate = time() - ($numberOfMonths * 60 * 60 * 24 * 30);
Severity: Minor
Found in lib/modules/Admin/Models/Db/Table/Statistics.php - About 1 hr to fix
Severity
Category
Status
Source
Language