Strimoid/Strimoid

View on GitHub

Showing 32 of 559 total issues

File lara.js has 607 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Bugsnag from '@bugsnag/js'
import Bloodhound from 'corejs-typeahead'
import loadjQueryPlugin from 'corejs-typeahead'
import Pusher from 'pusher-js'
import Echo from 'laravel-echo'
Severity: Major
Found in resources/assets/js/lara.js - About 1 day to fix

    User has 34 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class User extends BaseModel implements AuthenticatableContract, CanResetPasswordContract, AuthorizableContract
    {
        use Authenticatable, Authorizable, CanResetPassword, HasApiTokens, HasAvatar, Notifiable;
    
        protected string $avatarPath = 'avatars/';
    Severity: Minor
    Found in app/Models/User.php - About 4 hrs to fix

      Method getBuilder has 97 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function getBuilder(string $model): Builder
          {
              $builder = (new $model())->newQuery();
      
              $groups = [
      Severity: Major
      Found in app/Models/Folders/Popular.php - About 3 hrs to fix

        Method boot has 95 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function boot(): void
            {
                Validator::extend('unique_email', function ($attribute, $value, $parameters) {
                    if (isset($parameters[1])) {
                        $attribute = $parameters[1];
        Severity: Major
        Found in app/Providers/ValidatorServiceProvider.php - About 3 hrs to fix

          Method handle has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function handle(): void
              {
                  DB::connection()->disableQueryLog();
          
                  $conn = DB::connection();
          Severity: Major
          Found in app/Console/Commands/UpdateStats.php - About 2 hrs to fix

            Method boot has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function boot(Dispatcher $events): void
                {
                    $this->app->booted(function () {
                        if (Request::getUser() && Request::getPassword()) {
                            return Auth::onceBasic('name');
            Severity: Minor
            Found in app/Providers/EventsServiceProvider.php - About 1 hr to fix

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

              function VotesModule () {
              
                if (window.username) {
                  $('body').on('click', 'button.vote-btn-up', this.addUpvote)
                    .on('click', 'button.vote-btn-down', this.addDownvote)
              Severity: Minor
              Found in resources/assets/js/modules/votes.js - About 1 hr to fix

                Function handle has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function handle(): void
                    {
                        DB::connection()->disableQueryLog();
                
                        $conn = DB::connection();
                Severity: Minor
                Found in app/Console/Commands/UpdateStats.php - 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 store has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function store(Request $request): JsonResponse
                    {
                        $rules = [
                            'title' => 'required|min:1|max:128|not_in:edit,thumbnail',
                            'description' => 'max:255',
                Severity: Minor
                Found in app/Api/Controllers/ContentController.php - About 1 hr to fix

                  Method register has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function register(EnvironmentBuilderInterface $environment): void
                      {
                          $environment
                              ->addBlockStartParser(new Parser\Block\BlockQuoteStartParser(), 70)
                              ->addBlockStartParser(new Parser\Block\HeadingStartParser(), 60)
                  Severity: Minor
                  Found in app/Markdown/CoreExtension.php - About 1 hr to fix

                    Function addUpvote has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    VotesModule.prototype.addUpvote = function () {
                      var content = $(this).parent()
                      var cid = $(content).attr('data-id')
                      var state = $(content).attr('state')
                      var type = $(content).attr('data-type')
                    Severity: Minor
                    Found in resources/assets/js/modules/votes.js - About 1 hr to fix

                      Function addDownvote has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      VotesModule.prototype.addDownvote = function () {
                        var content = $(this).parent()
                        var cid = $(content).attr('data-id')
                        var state = $(content).attr('state')
                        var type = $(content).attr('data-type')
                      Severity: Minor
                      Found in resources/assets/js/modules/votes.js - About 1 hr to fix

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

                            function parse_usernames($body)
                            {
                                $body = preg_replace_callback('/(?<=^|\s)c\/([a-z0-9_-]+)(?=$|\s|:|.)/i', function ($matches) {
                                    $contentId = Hashids::decode($matches[1]);
                        
                        
                        Severity: Minor
                        Found in app/utils.php - About 1 hr to fix

                          Method getUrlAttribute has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function getUrlAttribute(): ?string
                              {
                                  $url = null;
                                  $params = null;
                          
                          
                          Severity: Minor
                          Found in app/Models/Notification.php - About 1 hr to fix

                            Function charCount has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              $.fn.charCount = function (options) {
                            
                                // default configuration properties
                                var defaults = {
                                  allowed: 140,
                            Severity: Minor
                            Found in resources/assets/js/plugins/jquery.charcount.js - About 1 hr to fix

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

                                  public function index(Request $request)
                                  {
                                      if ($request->has('folder')) {
                                          $username = request('user', auth()->id());
                                          $entity = $this->folders->getByName($username, request('folder'));
                              Severity: Minor
                              Found in app/Api/Controllers/ContentController.php - About 1 hr to fix

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

                                EntriesModule.prototype.editEntry = function (e) {
                                  var entry = $(this).parent().parent()
                                  var entry_id = $(entry).attr('data-id')
                                  var entry_old_text = $(entry).find('.entry_text').html()
                                  var type = (entry.hasClass('entry_reply') === true ? 'entry_reply' : 'entry')
                                Severity: Minor
                                Found in resources/assets/js/modules/entries.js - About 1 hr to fix

                                  Function NotificationsModule has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  function NotificationsModule () {
                                    var nm = this
                                  
                                    this.unreadNotifications = parseInt($('.notifications').attr('data-new-notifications'), 10)
                                    this.pageTitle = document.title
                                  Severity: Minor
                                  Found in resources/assets/js/modules/notifications.js - About 1 hr to fix

                                    Function handle has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        public function handle(): void
                                        {
                                            $x = 1;
                                    
                                            foreach (Group::all() as $group) {
                                    Severity: Minor
                                    Found in app/Console/Commands/GroupActivity.php - 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

                                    Function getUrlAttribute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        public function getUrlAttribute(): ?string
                                        {
                                            $url = null;
                                            $params = null;
                                    
                                    
                                    Severity: Minor
                                    Found in app/Models/Notification.php - 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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language