FarmBot/OpenFarm

View on GitHub

Showing 33 of 2,687 total issues

Function saveGuideChanges has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    $scope.saveGuideChanges = function() {
      var params = {
        data: {
          attributes: {
            overview: $scope.guide.overview,
Severity: Minor
Found in app/assets/javascripts/guides/show.js - About 1 hr to fix

    Function showCropCtrl has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function showCropCtrl($scope, $http, cropService, gardenService, userService, $interval) {
        $scope.alerts = [];
        $scope.s3upload = '';
        $scope.crop = {};
        $scope.userId = USER_ID || undefined;
    Severity: Minor
    Found in app/assets/javascripts/crops/show.js - About 1 hr to fix

      Method validate_favorite_guides has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate_favorite_guides
            current_guide_id = ''
            unless attributes[:favorited_guide_ids].nil?
              @favorited_guides = []
              attributes[:favorited_guide_ids].uniq.each do |guide_id|
      Severity: Minor
      Found in app/mutations/users/update_user.rb - About 55 mins 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

      Method find_overlap_in has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def find_overlap_in(basic_needs)
          stages.each do |stage|
            basic_needs.each do |need|
              # This is bad structure
              if need[:name] == "Sun / Shade"
      Severity: Minor
      Found in app/models/guide.rb - About 55 mins 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

      Method validate_images has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def validate_images (images, obj=nil)
          images && images.each do |pic|
            pic_id = "#{pic[:id]}" if pic[:id].present?
            pictures = obj.pictures if obj
      
      
      Severity: Minor
      Found in app/mutations/pictures_mixin.rb - About 45 mins 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

      Method show has a Cognitive Complexity of 8 (exceeds 5 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 45 mins 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

      Method validate_crop has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate_crop
            if crop_id
              @crop = Crop.find(crop_id)
            else
              @crop = check_if_crop_exists
      Severity: Minor
      Found in app/mutations/guides/create_guide.rb - About 35 mins 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

      Method compatibility_score has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def compatibility_score(current_user)
          return current_user_compatibility_score if current_user_compatibility_score
      
          return nil unless current_user
          return nil if current_user.gardens.blank?
      Severity: Minor
      Found in app/models/guide.rb - About 35 mins 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

      Method show? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def show?
          if @current_user
            if @current_user == @viewed_user || @current_user.admin
              true
            elsif @viewed_user.is_private?
      Severity: Minor
      Found in app/policies/user_policy.rb - About 35 mins 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 finishCtrl has a Cognitive Complexity of 7 (exceeds 5 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 35 mins 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 searchCtrl has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        function searchCtrl($scope, $http) {
          $scope.crops = [];
      
          // Redirect the browser to a specified crop
          //
      Severity: Minor
      Found in app/assets/javascripts/search.js - About 25 mins 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

      Method compatibility_label has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def compatibility_label(current_user)
          if current_user_compatibility_score
            score = current_user_compatibility_score
          else
            score = compatibility_score(current_user)
      Severity: Minor
      Found in app/models/guide.rb - About 25 mins 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

      Method validate_picture has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate_picture
            storage_type = Paperclip::Attachment.default_options[:storage]
            test_or_filesystem = storage_type.to_s != 'filesystem' ||
                                 Rails.env.to_s == 'test'
            if id
      Severity: Minor
      Found in app/mutations/pictures/create_picture.rb - About 25 mins 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

      Severity
      Category
      Status
      Source
      Language