diaspora/diaspora

View on GitHub

Showing 107 of 4,473 total issues

File user.rb has 457 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class User < ApplicationRecord
  include AuthenticationToken
  include Connecting
  include Querying
  include SocialActions
Severity: Minor
Found in app/models/user.rb - About 7 hrs to fix

    File publisher_view.js has 381 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
    
    /*   Copyright (c) 2010-2012, Diaspora Inc.  This file is
     *   licensed under the Affero General Public License version 3 or later.  See
     *   the COPYRIGHT file.
    Severity: Minor
    Found in app/assets/javascripts/app/views/publisher_view.js - About 5 hrs to fix

      Class AccountMigration has 32 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class AccountMigration < ApplicationRecord
        include Diaspora::Federated::Base
      
        belongs_to :old_person, class_name: "Person"
        belongs_to :new_person, class_name: "Person"
      Severity: Minor
      Found in app/models/account_migration.rb - About 4 hrs to fix

        Class Person has 32 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class Person < ApplicationRecord
          include Diaspora::Fields::Guid
        
          # NOTE API V1 to be extracted
          acts_as_api
        Severity: Minor
        Found in app/models/person.rb - About 4 hrs to fix

          File receive.rb has 306 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module Diaspora
            module Federation
              module Receive
                extend Diaspora::Logging
          
          
          Severity: Minor
          Found in lib/diaspora/federation/receive.rb - About 3 hrs to fix

            Class PostPresenter has 28 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class PostPresenter < BasePresenter
              include PostsHelper
              include MetaDataHelper
            
              attr_accessor :post
            Severity: Minor
            Found in app/presenters/post_presenter.rb - About 3 hrs to fix

              Class AuthorizationsController has 28 methods (exceeds 20 allowed). Consider refactoring.
              Open

                  class AuthorizationsController < ApplicationController
                    rescue_from Rack::OAuth2::Server::Authorize::BadRequest do |e|
                      logger.info e.backtrace[0, 10].join("\n")
                      error, _description = e.message.split(" :: ")
                      handle_params_error(error, "The request was malformed: please double check the client id and redirect uri.")
              Severity: Minor
              Found in app/controllers/api/openid_connect/authorizations_controller.rb - About 3 hrs to fix

                Function bookmarklet has a Cognitive Complexity of 21 (exceeds 5 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 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

                Router has 25 functions (exceeds 20 allowed). Consider refactoring.
                Open

                app.Router = Backbone.Router.extend({
                  routes: {
                    "activity(/)": "stream",
                    "admin/pods(/)": "adminPods",
                    "admins/dashboard(/)": "adminDashboard",
                Severity: Minor
                Found in app/assets/javascripts/app/router.js - About 2 hrs to fix

                  Publisher has 25 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  app.views.Publisher = Backbone.View.extend({
                  
                    el : "#publisher",
                  
                    events : {
                  Severity: Minor
                  Found in app/assets/javascripts/app/views/publisher_view.js - About 2 hrs to fix

                    File person.rb has 282 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    class Person < ApplicationRecord
                      include Diaspora::Fields::Guid
                    
                      # NOTE API V1 to be extracted
                      acts_as_api
                    Severity: Minor
                    Found in app/models/person.rb - About 2 hrs to fix

                      Class UsersController has 23 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      class UsersController < ApplicationController
                        before_action :authenticate_user!, except: %i(new create public)
                        respond_to :html
                      
                        def edit
                      Severity: Minor
                      Found in app/controllers/users_controller.rb - About 2 hrs to fix

                        Class ApplicationController has 23 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                        class ApplicationController < ActionController::Base
                          before_action :force_tablet_html
                          has_mobile_fu
                          protect_from_forgery except: :receive, with: :exception, prepend: true
                        
                        
                        Severity: Minor
                        Found in app/controllers/application_controller.rb - About 2 hrs to fix

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

                          class PersonPresenter < BasePresenter
                            def base_hash
                              {
                                id:          id,
                                guid:        guid,
                          Severity: Minor
                          Found in app/presenters/person_presenter.rb - About 2 hrs to fix

                            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
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language