fossasia/loklak_webclient

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

Summary

Maintainability
F
4 days
Test Coverage

File search.js has 311 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';
/* global angular, L, map */
/* jshint unused:false */

var controllersModule = require('./_index');
Severity: Minor
Found in app/js/controllers/search.js - About 3 hrs to fix

    Function filterMap has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        vm.filterMap = function() {
            cancelAllRequest();
            if (window.map) { delete(window.map); }
            vm.newStasuses = [];
            $rootScope.root.globalFilter = "map";
    Severity: Minor
    Found in app/js/controllers/search.js - About 1 hr to fix

      Function addListenersOnMap has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function addListenersOnMap() {
              window.map.on("zoomend", function(event) {
                  if (!prevZoomAction) {
                      prevZoomAction = new Date();
                      getMoreLocationOnMapAction();
      Severity: Minor
      Found in app/js/controllers/search.js - About 1 hr to fix

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

            function addListenersOnMap() {
                window.map.on("zoomend", function(event) {
                    if (!prevZoomAction) {
                        prevZoomAction = new Date();
                        getMoreLocationOnMapAction();
        Severity: Major
        Found in app/js/controllers/search.js and 1 other location - About 1 day to fix
        app/js/controllers/advanced-search.js on lines 325..352

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

        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

            vm.openSwipe = function(status_id) {
                var items = [];
                var images  = angular.element('#' + status_id + ' .images-wrapper img');
                var options = { index: 0, history: false};
                var swipeEle = document.querySelectorAll('.pswp')[0];
        Severity: Major
        Found in app/js/controllers/search.js and 1 other location - About 7 hrs to fix
        app/js/controllers/topology.js on lines 99..113

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

        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

            function getMoreLocationOnMapAction() {
                var bound = window.map.getBounds();
                var locationTerm = MapCreationService.getLocationParamFromBound(bound);
                var params = { q: vm.term + "+" + locationTerm, count: 300};
                SearchService.initData(params).then(function(data) {
        Severity: Major
        Found in app/js/controllers/search.js and 1 other location - About 5 hrs to fix
        app/js/controllers/advanced-search.js on lines 316..323

        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 (!vm.peopleSearch) {
                    if (vm.pool.length < (2 * amount + 1)) {
                        getMoreStatuses();
                    }
                    vm.statuses = vm.statuses.concat(vm.pool.slice(0,amount));
        Severity: Major
        Found in app/js/controllers/search.js and 1 other location - About 3 hrs to fix
        app/js/controllers/topology.js on lines 44..51

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

        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

                SearchService.getData(term).then(function(data) {
                       vm.pool = data.statuses;
                       vm.statuses = [];
                       $scope.loadMore(20);
                       vm.showResult = true;
        Severity: Major
        Found in app/js/controllers/search.js and 1 other location - About 2 hrs to fix
        app/js/controllers/search.js on lines 399..405

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

        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

                        SearchService.getData(vm.term).then(function(data) {
                               vm.pool = data.statuses;
                               vm.statuses = [];
                               $scope.loadMore(20);
                               vm.showResult = true;
        Severity: Major
        Found in app/js/controllers/search.js and 1 other location - About 2 hrs to fix
        app/js/controllers/search.js on lines 143..149

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

        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

                    SearchService.initData(params).then(function(data) {
                           vm.pool = vm.pool.concat(data.statuses);
                    }, function() {});
        Severity: Major
        Found in app/js/controllers/search.js and 1 other location - About 1 hr to fix
        app/js/controllers/topology.js on lines 31..33

        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

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

                            if (status.videos[0].substr(-4) === '.mp4') {
                                status.links[0] = status.videos[0];
                            }
        Severity: Minor
        Found in app/js/controllers/search.js and 1 other location - About 50 mins to fix
        app/js/controllers/advanced-search.js on lines 281..283

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

        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