GrafiteInc/CMS

View on GitHub

Showing 103 of 103 total issues

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

    public function handle()
    {
        $moduleDir = base_path(config('cms.module-directory')).'/'.ucfirst($this->argument('module'));
        if (is_dir($moduleDir)) {
            $readMeStub = file_get_contents(__DIR__.'/../Templates/Composer/readme.stub');
Severity: Minor
Found in src/Console/ModuleComposer.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 saveFile has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function saveFile($fileName, $directory = '', $fileTypes = [], $isImage = false)
    {
        if (is_object($fileName)) {
            $file = $fileName;
            $originalName = $file->getClientOriginalName();
Severity: Minor
Found in src/Services/FileService.php - About 1 hr to fix

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

        $(".cms-notify-closer").click(function(){
            $(".cms-notification").animate({
                right: "-300px"
            },"", function(){
                $(".cms-notification").css("display", "none");
    Severity: Major
    Found in src/Assets/src/js/cms.js and 1 other location - About 1 hr to fix
    src/Assets/src/js/cms.js on lines 94..101

    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 65.

    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

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

        setTimeout(function(){
            $(".cms-notification").animate({
                right: "-300px"
            },"", function(){
                $(".cms-notification").css("display", "none");
    Severity: Major
    Found in src/Assets/src/js/cms.js and 1 other location - About 1 hr to fix
    src/Assets/src/js/cms.js on lines 85..92

    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 65.

    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 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function handle()
        {
            $name = $this->argument('name');
    
            $fileSystem = new Filesystem();
    Severity: Minor
    Found in src/Console/ThemeGenerate.php - About 1 hr to fix

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

      <?php
      
      use Illuminate\Support\Facades\Schema;
      use Illuminate\Database\Schema\Blueprint;
      use Illuminate\Database\Migrations\Migration;
      Severity: Major
      Found in src/Migrations/2017_06_10_234231_add_order_to_menus.php and 2 other locations - About 1 hr to fix
      src/Migrations/2016_02_03_175046_add_tags_to_images.php on lines 1..27
      src/Migrations/2016_12_11_034855_add_lang_to_translations_table.php on lines 1..28

      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 110.

      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 3 locations. Consider refactoring.
      Open

      <?php
      
      use Illuminate\Database\Migrations\Migration;
      use Illuminate\Database\Schema\Blueprint;
      
      
      Severity: Major
      Found in src/Migrations/2016_02_03_175046_add_tags_to_images.php and 2 other locations - About 1 hr to fix
      src/Migrations/2016_12_11_034855_add_lang_to_translations_table.php on lines 1..28
      src/Migrations/2017_06_10_234231_add_order_to_menus.php on lines 1..28

      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 110.

      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 3 locations. Consider refactoring.
      Open

      <?php
      
      use Illuminate\Support\Facades\Schema;
      use Illuminate\Database\Schema\Blueprint;
      use Illuminate\Database\Migrations\Migration;
      src/Migrations/2016_02_03_175046_add_tags_to_images.php on lines 1..27
      src/Migrations/2017_06_10_234231_add_order_to_menus.php on lines 1..28

      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 110.

      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 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function handle()
          {
              if (is_dir(base_path(Config::get('cms.module-directory')).DIRECTORY_SEPARATOR.ucfirst($this->argument('module')).DIRECTORY_SEPARATOR.'Publishes')) {
                  $fileSystem = new Filesystem();
      
      
      Severity: Minor
      Found in src/Console/ModulePublish.php - About 1 hr to fix

        Function menus has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            public function menus()
            {
                $modulePath = base_path(config('cms.module-directory').'/');
                $modules = glob($modulePath.'*');
        
        
        Severity: Minor
        Found in src/Services/ModuleService.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 check has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function check($form, $jsonInput = false)
            {
                $result = [];
                $errors = [];
                $inputs = [];
        Severity: Minor
        Found in src/Services/ValidationService.php - About 1 hr to fix

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

              public function afterCreate($payload)
              {
                  if (config('cms.auto-translate', false)) {
                      $entry = $payload->toArray();
          
          
          Severity: Minor
          Found in src/Traits/Translatable.php - About 1 hr to fix

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

                public function convertDataToItems($data, $key, $conversions = [], $limit = 15)
                {
                    if (!isset($conversions['unknown'])) {
                        $conversions['unknown'] = 0;
                    }
            Severity: Minor
            Found in src/Services/AnalyticsService.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

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

                function sortable($label, $field)
                {
                    $query = request()->query();
                    $newQuery = $query;
            
            
            Severity: Minor
            Found in src/Helpers/general.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

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

                public function moduleLinks($ignoredModules = [], $linkClass = 'nav-link', $listClass = 'nav-item')
                {
                    $links = '';
            
                    $modules = config('cms.modules', []);
            Severity: Minor
            Found in src/Services/Traits/ModuleServiceTrait.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 handle has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function handle()
                {
                    $moduleDir = base_path(config('cms.module-directory')).'/'.ucfirst($this->argument('module'));
                    if (is_dir($moduleDir)) {
                        $readMeStub = file_get_contents(__DIR__.'/../Templates/Composer/readme.stub');
            Severity: Minor
            Found in src/Console/ModuleComposer.php - About 1 hr to fix

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

                  public function handle()
                  {
                      $name = $this->argument('name');
              
                      $fileSystem = new Filesystem();
              Severity: Minor
              Found in src/Console/ThemePublish.php - About 1 hr to fix

                Function check has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function check($form, $jsonInput = false)
                    {
                        $result = [];
                        $errors = [];
                        $inputs = [];
                Severity: Minor
                Found in src/Services/ValidationService.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

                Function promotion has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function promotion($slug)
                    {
                        $promotion = app(PromotionRepository::class)->getBySlug($slug);
                
                        if ($promotion) {
                Severity: Minor
                Found in src/Services/Traits/DefaultModuleServiceTrait.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 preview has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function preview($entity, $id)
                    {
                        $modelString = 'Grafite\Cms\Models\\'.ucfirst($entity);
                
                        if (!class_exists($modelString)) {
                Severity: Minor
                Found in src/Controllers/GrafiteCmsFeatureController.php - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language