FarmBot/OpenFarm

View on GitHub

Showing 33 of 2,687 total issues

Function newGuideCtrl has 313 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function newGuideCtrl(
    $scope,
    $http,
    $q,
    guideService,
Severity: Major
Found in app/assets/javascripts/guides/new.js - About 1 day to fix

    Function newGuideCtrl has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
    Open

      function newGuideCtrl(
        $scope,
        $http,
        $q,
        guideService,
    Severity: Minor
    Found in app/assets/javascripts/guides/new.js - About 1 day 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 showGuideCtrl has 214 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function showGuideCtrl(
        $scope,
        $http,
        guideService,
        $q,
    Severity: Major
    Found in app/assets/javascripts/guides/show.js - About 1 day to fix

      Function showGuideCtrl has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

        function showGuideCtrl(
          $scope,
          $http,
          guideService,
          $q,
      Severity: Minor
      Found in app/assets/javascripts/guides/show.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

      File new.js has 348 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      openFarmApp.config([
        '$locationProvider',
        function($locationProvider) {
          $locationProvider.html5Mode(false).hashPrefix('!');
        },
      Severity: Minor
      Found in app/assets/javascripts/guides/new.js - About 4 hrs to fix

        Function cropCtrl has 104 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function cropCtrl($scope, $http, cropService) {
            $scope.s3upload = '';
            $scope.crop = {};
        
            var cropId = getIDFromURL('crops');
        Severity: Major
        Found in app/assets/javascripts/crops/edit.js - About 4 hrs to fix

          Function gardenCtrl has 100 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function gardenCtrl($scope, $http, $rootScope, userService, gardenService, cropService) {
              $scope.addingGarden = false;
              $scope.addingCrop = false;
              $scope.newGarden = {};
          
          
          Severity: Major
          Found in app/assets/javascripts/users/gardens.js - About 4 hrs to fix

            Function gardenCtrl has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
            Open

              function gardenCtrl($scope, $http, $rootScope, userService, gardenService, cropService) {
                $scope.addingGarden = false;
                $scope.addingCrop = false;
                $scope.newGarden = {};
            
            
            Severity: Minor
            Found in app/assets/javascripts/users/gardens.js - About 3 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 setCurrentUser has 80 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                $scope.setCurrentUser = function(success, object) {
                  if (success) {
                    $scope.currentUser = object;
            
                    $scope.currentUser.gardens.forEach(function(g) {
            Severity: Major
            Found in app/assets/javascripts/guides/show.js - About 3 hrs to fix

              Function cropCtrl has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

                function cropCtrl($scope, $http, cropService) {
                  $scope.s3upload = '';
                  $scope.crop = {};
              
                  var cropId = getIDFromURL('crops');
              Severity: Minor
              Found in app/assets/javascripts/crops/edit.js - About 2 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 createStageData has 62 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function createStageData(stage, guide) {
                    var data = {};
                    var stageActions = [];
                    if (stage.selected) {
                      if (stage.stage_action_options) {
              Severity: Major
              Found in app/assets/javascripts/guides/new.js - About 2 hrs to fix

                Function profileCtrl has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                  function profileCtrl($scope, $rootScope, $http, userService) {
                    $scope.profileId = PROFILE_ID || undefined;
                    $scope.userId = USER_ID || undefined;
                
                    $scope.query = '';
                Severity: Minor
                Found in app/assets/javascripts/users/show.js - About 2 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 submitForm has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function submitForm() {
                      $scope.crop.sending = true;
                
                      var commonNames = $scope.crop.common_names;
                      if (typeof $scope.crop.common_names === 'string') {
                Severity: Major
                Found in app/assets/javascripts/crops/edit.js - About 2 hrs to fix

                  Function activate has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      function activate() {
                        // First FIRST we need to get all of the defaults
                        $q.all([
                          defaultService.processedDetailOptions(),
                          cropService.getCropWithPromise(getUrlVar('crop_id')),
                  Severity: Minor
                  Found in app/assets/javascripts/guides/new.js - About 1 hr to fix

                    Function buildParametersFromScope has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        var buildParametersFromScope = function() {
                          // Gather things in the scope and put them in parameters.
                    
                          angular.forEach($scope.newGuide.time_span, function(val, key) {
                            $scope.newGuide.time_span[key] = val || undefined;
                    Severity: Minor
                    Found in app/assets/javascripts/guides/new.js - About 1 hr to fix

                      Function profileCtrl has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        function profileCtrl($scope, $rootScope, $http, userService) {
                          $scope.profileId = PROFILE_ID || undefined;
                          $scope.userId = USER_ID || undefined;
                      
                          $scope.query = '';
                      Severity: Minor
                      Found in app/assets/javascripts/users/show.js - About 1 hr to fix

                        Method show has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def show
                            token = params.require(:confirmation_token).encode!(
                              "UTF-8",
                              "binary",
                              invalid: :replace,
                        Severity: Minor
                        Found in app/controllers/confirmations_controller.rb - About 1 hr to fix

                          Function finishCtrl has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            function finishCtrl($scope, $http, userService) {
                              $scope.userId = USER_ID || undefined;
                          
                              $scope.setUser = function(success, object) {
                                if (success) {
                          Severity: Minor
                          Found in app/assets/javascripts/users/finish.js - About 1 hr to fix

                            Method basic_needs has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def basic_needs(current_user)
                                return nil unless current_user
                                return nil if current_user.gardens.blank?
                            
                                first_garden = current_user.gardens.first
                            Severity: Minor
                            Found in app/models/guide.rb - About 1 hr to fix

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

                                  function favoriteGuide(guideId) {
                                    if (!$scope.currentUser) {
                                      alertsService.pushToAlerts(['You need to log in to mark your favorite'], 401);
                                    } else {
                                      $scope.updatingFavoritedGuides = true;
                              Severity: Minor
                              Found in app/assets/javascripts/guides/show.js - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language