fossasia/loklak_webclient

View on GitHub
app/js/controllers/wallDisplay.js

Summary

Maintainability
F
1 wk
Test Coverage

Function WallDisplay has a Cognitive Complexity of 195 (exceeds 5 allowed). Consider refactoring.
Open

function WallDisplay($scope, $stateParams, $interval, $timeout, $location, $http, $window, $resource, AppSettings, SearchService, StatisticsService, AppsService, Fullscreen) {

    var vm, flag, allStatuses, nextStatuses, term, count, searchParams, maxStatusCount;
    vm = this;
    vm.invalidId = false;
Severity: Minor
Found in app/js/controllers/wallDisplay.js - About 3 days 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 WallDisplay has 403 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function WallDisplay($scope, $stateParams, $interval, $timeout, $location, $http, $window, $resource, AppSettings, SearchService, StatisticsService, AppsService, Fullscreen) {

    var vm, flag, allStatuses, nextStatuses, term, count, searchParams, maxStatusCount;
    vm = this;
    vm.invalidId = false;
Severity: Major
Found in app/js/controllers/wallDisplay.js - About 2 days to fix

    File wallDisplay.js has 412 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    /* global angular */
    /* jshint unused:false */
    
    var controllersModule = require('./_index');
    Severity: Minor
    Found in app/js/controllers/wallDisplay.js - About 5 hrs to fix

      Function calculateTerm has 80 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function calculateTerm(argument) {
              term = "";
      
              var i;
              for (i = 0; i < vm.wallOptions.all.length; i++) {
      Severity: Major
      Found in app/js/controllers/wallDisplay.js - About 3 hrs to fix

        Function evalHistogram has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function evalHistogram(statistics) {
                if (Object.getOwnPropertyNames(statistics.created_at).length !== 0) {
                    var data = [];
                    var labels = [];
                    var chosen_attr = statistics.created_at;
        Severity: Major
        Found in app/js/controllers/wallDisplay.js - About 2 hrs to fix

          Function update2 has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              vm.update2 = function(refreshTime) {
                  return $timeout(function() {
                      SearchService.initData(searchParams).then(function(data) {
                          if (data.statuses) {
                              if (data.statuses.length <= 0) {
          Severity: Minor
          Found in app/js/controllers/wallDisplay.js - About 1 hr to fix

            Function WallDisplay has 13 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function WallDisplay($scope, $stateParams, $interval, $timeout, $location, $http, $window, $resource, AppSettings, SearchService, StatisticsService, AppsService, Fullscreen) {
            Severity: Major
            Found in app/js/controllers/wallDisplay.js - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                                              if (vm.wallOptions.cycle) {
                                                  if (!contains(vm.statuses, data.statuses[i])) {
                                                      console.log("triggered");
                                                      removeLeastRecentTweet();
                                                      $interval.cancel(cycleInterval);
              Severity: Major
              Found in app/js/controllers/wallDisplay.js - About 45 mins to fix

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

                    function scrapeImgTag(imgTag) {
                        var ngEle = angular.element(imgTag);
                        return {
                            src: ngEle.attr('src'),
                            w: parseInt(ngEle.css('width').replace('px', '')),
                Severity: Major
                Found in app/js/controllers/wallDisplay.js and 2 other locations - About 2 hrs to fix
                app/js/controllers/single-tweet.js on lines 47..54
                app/js/controllers/topology.js on lines 85..92

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

                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

                        if (vm.wallOptions.images) {
                            if (vm.wallOptions.images === "only") {
                                term = term + ' /image';
                            } else if (vm.wallOptions.images === "none") {
                                term = term + ' -/image';
                Severity: Major
                Found in app/js/controllers/wallDisplay.js and 2 other locations - About 2 hrs to fix
                app/js/controllers/wallDisplay.js on lines 62..68
                app/js/controllers/wallDisplay.js on lines 70..76

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

                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

                        if (vm.wallOptions.audio) {
                            if (vm.wallOptions.audio === "only") {
                                term = term + ' /audio';
                            } else if (vm.wallOptions.audio === "none") {
                                term = term + ' -/audio';
                Severity: Major
                Found in app/js/controllers/wallDisplay.js and 2 other locations - About 2 hrs to fix
                app/js/controllers/wallDisplay.js on lines 54..60
                app/js/controllers/wallDisplay.js on lines 62..68

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

                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

                        if (vm.wallOptions.videos) {
                            if (vm.wallOptions.videos === "only") {
                                term = term + ' /video';
                            } else if (vm.wallOptions.videos === "none") {
                                term = term + ' -/video';
                Severity: Major
                Found in app/js/controllers/wallDisplay.js and 2 other locations - About 2 hrs to fix
                app/js/controllers/wallDisplay.js on lines 54..60
                app/js/controllers/wallDisplay.js on lines 70..76

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

                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

                        for (i = 0; i < vm.wallOptions.none.length; i++) {
                            term = term + ' -' + vm.wallOptions.none[i].text;
                        }
                Severity: Major
                Found in app/js/controllers/wallDisplay.js and 2 other locations - About 1 hr to fix
                app/js/controllers/wallDisplay.js on lines 24..26
                app/js/controllers/wallDisplay.js on lines 34..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 64.

                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

                        for (i = 0; i < vm.wallOptions.all.length; i++) {
                            term = term + ' ' + vm.wallOptions.all[i].text;
                        }
                Severity: Major
                Found in app/js/controllers/wallDisplay.js and 2 other locations - About 1 hr to fix
                app/js/controllers/wallDisplay.js on lines 28..30
                app/js/controllers/wallDisplay.js on lines 34..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 64.

                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

                            for (i = 1; i < vm.wallOptions.any.length; i++) {
                                term = term + ' OR ' + vm.wallOptions.any[i].text;
                            }
                Severity: Major
                Found in app/js/controllers/wallDisplay.js and 2 other locations - About 1 hr to fix
                app/js/controllers/wallDisplay.js on lines 24..26
                app/js/controllers/wallDisplay.js on lines 28..30

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

                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

                    function compareP(a, b) {
                        if (a.screen_name < b.screen_name) {
                            return -1;
                        } else if (a.screen_name > b.screen_name) {
                            return 1;
                Severity: Major
                Found in app/js/controllers/wallDisplay.js and 1 other location - About 1 hr to fix
                app/js/controllers/wallDisplay.js on lines 242..249

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

                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

                    function compare(a, b) {
                        if (a.created_at < b.created_at) {
                            return -1;
                        } else if (a.created_at > b.created_at) {
                            return 1;
                Severity: Major
                Found in app/js/controllers/wallDisplay.js and 1 other location - About 1 hr to fix
                app/js/controllers/wallDisplay.js on lines 331..338

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

                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

                    function contains(Statuses, status) {
                        for (var i = 0; i < Statuses.length; i++) {
                            if (Statuses[i].id_str === status.id_str) {
                                return true;
                            }
                Severity: Major
                Found in app/js/controllers/wallDisplay.js and 1 other location - About 1 hr to fix
                app/js/directives/mapLayout.js on lines 86..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 60.

                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