Strimoid/Strimoid

View on GitHub

Showing 559 of 559 total issues

Similar blocks of code found in 5 locations. Consider refactoring.
Open

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
database/migrations/2015_03_20_144839_create_user_blocked_groups_table.php on lines 1..36
database/migrations/2015_03_20_144856_create_user_subscribed_groups_table.php on lines 1..36
database/migrations/2015_03_20_151518_create_user_blocked_users_table.php on lines 1..36
database/migrations/2015_03_20_155500_create_folder_groups_table.php on lines 1..36

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 134.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          bootbox.confirm('Na pewno chcesz usunąć wybraną treść?', function (result) {
            if (result)
              $.post('/ajax/content/remove', { id: content_id }, function (data) {
                if (data.status === 'ok')
                  window.location.href = '/'
      Severity: Major
      Found in resources/assets/js/lara.js and 1 other location - About 1 hr to fix
      resources/assets/js/modules/folders.js on lines 80..86

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 74.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        bootbox.confirm('Na pewno chcesz usunąć wybrany folder?', function (result) {
          if (result)
            $.post('/ajax/folder/remove', { folder: id }, function (data) {
              if (data.status === 'ok')
                window.location.href = '/'
      Severity: Major
      Found in resources/assets/js/modules/folders.js and 1 other location - About 1 hr to fix
      resources/assets/js/lara.js on lines 178..184

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 74.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          if (button.hasClass('glyphicon-star')) {
            $.post('/ajax/content/remove_save', { content: content }, function (data) {
              if (data.status === 'ok') {
                $(button).removeClass('glyphicon-star')
                $(button).addClass('glyphicon-star-empty')
        Severity: Major
        Found in resources/assets/js/modules/contents.js and 1 other location - About 1 hr to fix
        resources/assets/js/modules/contents.js on lines 25..32

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 73.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          } else {
            $.post('/ajax/folder/remove_group', { folder: $(this).attr('data-id'), group: group }, function (data) {
              if (data.status === 'ok')
                $(input).prop('disabled', false)
            })
        Severity: Major
        Found in resources/assets/js/modules/folders.js and 1 other location - About 1 hr to fix
        resources/assets/js/modules/folders.js on lines 39..45

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 73.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          $('body').on('click', '.entry .show_blocked_link', function () {
            $(this).parent().parent().find('.entry_text.blocked').removeClass('blocked')
            $(this).remove()
          })
        Severity: Major
        Found in resources/assets/js/lara.js and 1 other location - About 1 hr to fix
        resources/assets/js/lara.js on lines 329..332

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 73.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          } else {
            $.post('/ajax/content/add_save', { content: content }, function (data) {
              if (data.status === 'ok') {
                $(button).removeClass('glyphicon-star-empty')
                $(button).addClass('glyphicon-star')
        Severity: Major
        Found in resources/assets/js/modules/contents.js and 1 other location - About 1 hr to fix
        resources/assets/js/modules/contents.js on lines 18..25

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 73.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          if (this.checked) {
            $.post('/ajax/folder/add_group', { folder: $(this).attr('data-id'), group: group }, function (data) {
              if (data.status === 'ok')
                $(input).prop('disabled', false)
            })
        Severity: Major
        Found in resources/assets/js/modules/folders.js and 1 other location - About 1 hr to fix
        resources/assets/js/modules/folders.js on lines 45..50

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 73.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          $('body').on('click', '.comment .show_blocked_link', function () {
            $(this).parent().parent().find('.comment_text.blocked').removeClass('blocked')
            $(this).remove()
          })
        Severity: Major
        Found in resources/assets/js/lara.js and 1 other location - About 1 hr to fix
        resources/assets/js/lara.js on lines 324..327

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 73.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        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

          Avoid excessively long variable names like $newNotificationsCount. Keep variable name length under 20.
          Open

                  $newNotificationsCount = Notification::target(['user_id' => $this->authManager->id(), 'read' => false]);

          LongVariable

          Since: 0.2

          Detects when a field, formal or local variable is declared with a long name.

          Example

          class Something {
              protected $reallyLongIntName = -3; // VIOLATION - Field
              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                  $otherReallyLongName = -5; // VIOLATION - Local
                  for ($interestingIntIndex = 0; // VIOLATION - For
                       $interestingIntIndex < 10;
                       $interestingIntIndex++ ) {
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#longvariable

          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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              } else {
                $.post('/ajax/entry/add_save', { entry: entry }, function (data) {
                  if (data.status === 'ok') {
                    $(button).removeClass('fa-star-o').addClass('fa-star')
                  }
            Severity: Major
            Found in resources/assets/js/modules/entries.js and 1 other location - About 1 hr to fix
            resources/assets/js/modules/entries.js on lines 18..24

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 66.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              if (button.hasClass('fa-star')) {
                $.post('/ajax/entry/remove_save', { entry: entry }, function (data) {
                  if (data.status === 'ok') {
                    $(button).removeClass('fa-star').addClass('fa-star-o')
                  }
            Severity: Major
            Found in resources/assets/js/modules/entries.js and 1 other location - About 1 hr to fix
            resources/assets/js/modules/entries.js on lines 24..30

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 66.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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

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