diaspora/diaspora

View on GitHub

Showing 124 of 4,306 total issues

Class NodeInfoPresenter has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

class NodeInfoPresenter
  delegate :as_json, :content_type, to: :document

  def initialize(version)
    @version = version
Severity: Minor
Found in app/presenters/node_info_presenter.rb - About 2 hrs to fix

    Function createStatusMessage has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      createStatusMessage : function(evt) {
        this.setButtonsEnabled(false);
        var self = this;
    
        if(evt){ evt.preventDefault(); }
    Severity: Minor
    Found in app/assets/javascripts/app/views/publisher_view.js - About 1 hr to fix

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

        initialize : function() {
          this.GETTING_HELP_SUBS = {
            getting_started_a: {tutorial_series: this.linkHtml("http://diasporafoundation.org/getting_started/sign_up", Diaspora.I18n.t("getting_started_tutorial"))},
            get_support_a_website: {link: this.linkHtml("https://diasporafoundation.org/", Diaspora.I18n.t("foundation_website"))},
            get_support_a_tutorials: {tutorials: this.linkHtml("https://diasporafoundation.org/tutorials", Diaspora.I18n.t("tutorials"))},
      Severity: Minor
      Found in app/assets/javascripts/app/views/help_view.js - About 1 hr to fix

        Method mobile_reshare_icon has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def mobile_reshare_icon(post)
            if (post.public? || reshare?(post)) && (user_signed_in? && post.author != current_user.person)
              absolute_root = reshare?(post) ? post.absolute_root : post
        
              if absolute_root && absolute_root.author != current_user.person
        Severity: Minor
        Found in app/helpers/mobile_helper.rb - 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 UsersGettingStarted has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Diaspora.Pages.UsersGettingStarted = function() {
          var self = this;
        
          this.subscribe("page/ready", function(evt, body) {
            self.peopleSearch = self.instantiate("Search", body.find("form.people.search_form"));
        Severity: Minor
        Found in app/assets/javascripts/pages/users-getting-started.js - About 1 hr to fix

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

            var profileAspectDropDown_onchange = function() {
              var $el      = $(this),
                  selected = $el.find('option:selected');
              $el.find('option.list_cover').text(Diaspora.I18n.t('aspect_dropdown.updating'));
              $el.val('list_cover'); // switch back to cover
          Severity: Minor
          Found in app/assets/javascripts/mobile/profile_aspects.js - About 1 hr to fix

            Method munge_tag_string has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

              def munge_tag_string
                unless @profile_attrs[:tag_string].nil? || @profile_attrs[:tag_string] == I18n.t('profiles.edit.your_tags_placeholder')
                  @profile_attrs[:tag_string].split( " " ).each do |extra_tag|
                    extra_tag.strip!
                    unless extra_tag == ""
            Severity: Minor
            Found in app/controllers/profiles_controller.rb - 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 initialize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

              initialize: function() {
                new qq.FineUploaderBasic({
                  element: document.getElementById("file-upload"),
                  validation: {
                    allowedExtensions: ["jpg", "jpeg", "png"],
            Severity: Minor
            Found in app/assets/javascripts/helpers/profile_photo_uploader.js - 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

            Method legacy_create has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

              def legacy_create
                photo_params = params.require(:photo).permit(:pending, :set_profile_photo, aspect_ids: [])
                if photo_params[:aspect_ids] == "all"
                  photo_params[:aspect_ids] = current_user.aspects.map(&:id)
                elsif photo_params[:aspect_ids].is_a?(Hash)
            Severity: Minor
            Found in app/controllers/photos_controller.rb - 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 bookmarklet has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            var bookmarklet = function(url, width, height, opts) {
              var maxLen = 1900; // max GET request length, see #3076
              var maxTitleLen = 128; // cut title after this length, if too long
            
              // calculate popup dimensions & placement
            Severity: Minor
            Found in app/assets/javascripts/bookmarklet.js - About 1 hr to fix

              Function initialize has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                initialize: function(opts) {
                  this.publisher = opts.publisher;
                  this.uploader = new qq.FineUploaderBasic({
                    element: this.el,
                    button: this.el,
              Severity: Minor
              Found in app/assets/javascripts/app/views/publisher/uploader_view.js - About 1 hr to fix

                Method destroy has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  def destroy
                    aspect = current_user.aspects.joins(:aspect_memberships).where(aspect_memberships: {id: params[:id]}).first
                    contact = current_user.contacts.joins(:aspect_memberships).where(aspect_memberships: {id: params[:id]}).first
                
                    raise ActiveRecord::RecordNotFound unless aspect.present? && contact.present?
                Severity: Minor
                Found in app/controllers/aspect_memberships_controller.rb - 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 onComplete has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      onComplete: function(_id, fileName, responseJSON) {
                        if (responseJSON.data === undefined) {
                          return;
                        }
                
                
                Severity: Minor
                Found in app/assets/javascripts/mobile/mobile_file_uploader.js - About 1 hr to fix

                  Function initialize has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    initialize : function(opts){
                      this.standalone = opts ? opts.standalone : false;
                      this.prefillMention = opts && opts.prefillMention ? opts.prefillMention : undefined;
                      this.disabled   = false;
                  
                  
                  Severity: Minor
                  Found in app/assets/javascripts/app/views/publisher_view.js - About 1 hr to fix

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

                      createStatusMessage : function(evt) {
                        this.setButtonsEnabled(false);
                        var self = this;
                    
                        if(evt){ evt.preventDefault(); }
                    Severity: Minor
                    Found in app/assets/javascripts/app/views/publisher_view.js - 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

                    Method set_grammatical_gender has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def set_grammatical_gender
                        if (user_signed_in? && I18n.inflector.inflected_locale?)
                          gender = current_user.gender.to_s.tr('!()[]"\'`*=|/\#.,-:', '').downcase
                          unless gender.empty?
                            i_langs = I18n.inflector.inflected_locales(:gender)
                    Severity: Minor
                    Found in app/controllers/application_controller.rb - 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 createPostPreview has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      createPostPreview: function() {
                        var serializedForm = $("#new_status_message").serializeObject();
                        var photos = this.getUploadedPhotos();
                        var poll = this.getPollData(serializedForm);
                        var locationCoords = serializedForm["location[coords]"];
                    Severity: Minor
                    Found in app/assets/javascripts/app/views/publisher_view.js - About 1 hr to fix

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

                        def legacy_create
                          photo_params = params.require(:photo).permit(:pending, :set_profile_photo, aspect_ids: [])
                          if photo_params[:aspect_ids] == "all"
                            photo_params[:aspect_ids] = current_user.aspects.map(&:id)
                          elsif photo_params[:aspect_ids].is_a?(Hash)
                      Severity: Minor
                      Found in app/controllers/photos_controller.rb - About 1 hr to fix

                        Method index has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def index
                            conditions = {:recipient_id => current_user.id}
                            if params[:type] && types.has_key?(params[:type])
                              conditions[:type] = types[params[:type]]
                            end
                        Severity: Minor
                        Found in app/controllers/notifications_controller.rb - About 1 hr to fix

                          Method copy_hidden_share_visibilities_to_users has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def self.copy_hidden_share_visibilities_to_users(only_recent = false)
                              query = ShareVisibility.where(:hidden => true).includes(:contact => :user)
                              query = query.where('share_visibilities.updated_at > ?', RECENT.weeks.ago) if only_recent
                              count = query.count
                              puts "Updating #{count} records in batches of 1000..."
                          Severity: Minor
                          Found in lib/share_visibility_converter.rb - 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

                          Severity
                          Category
                          Status
                          Source