GrafiteInc/CMS

View on GitHub

Showing 103 of 103 total issues

Method asPreview has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function asPreview($encFileName, Filesystem $fileSystem)
    {
        try {
            return Cache::remember($encFileName.'_preview', 3600, function () use ($encFileName, $fileSystem) {
                $fileName = CryptoServiceFacade::url_decode($encFileName);
Severity: Minor
Found in src/Services/AssetService.php - About 1 hr to fix

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

        public function register()
        {
            $loader = AliasLoader::getInstance();
    
            $loader->alias('Cms', \Grafite\Cms\Facades\CmsServiceFacade::class);
    Severity: Minor
    Found in src/Providers/CmsServiceProvider.php - About 1 hr to fix

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

          public function makeTheProvider($config, $moduleDirectory, $table)
          {
              $provider = file_get_contents(__DIR__.'/../Templates/Basic/Provider.txt');
      
              foreach ($config as $key => $value) {
      Severity: Major
      Found in src/Console/ModuleMake.php and 1 other location - About 1 hr to fix
      src/Console/ModuleCrud.php on lines 177..186

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

      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

          public function makeTheProvider($config, $moduleDirectory, $table)
          {
              $provider = file_get_contents(__DIR__.'/../Templates/CRUD/Provider.txt');
      
              foreach ($config as $key => $value) {
      Severity: Major
      Found in src/Console/ModuleCrud.php and 1 other location - About 1 hr to fix
      src/Console/ModuleMake.php on lines 142..151

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

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

                          if (is_dir($file)) {
                              $fileSystem->copyDirectory($file, base_path($newFileName));
                          } else {
                              @mkdir(base_path(str_replace(basename($newFileName), '', $newFileName)), 0755, true);
                              $fileSystem->copy($file, base_path($newFileName));
      Severity: Major
      Found in src/Console/ModulePublish.php and 2 other locations - About 1 hr to fix
      src/Console/ThemeGenerate.php on lines 50..55
      src/Console/ThemePublish.php on lines 55..60

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

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

                      if (is_dir($file)) {
                          $fileSystem->copyDirectory($file, base_path($newFileName));
                      } else {
                          @mkdir(base_path(str_replace(basename($newFileName), '', $newFileName)), 0755, true);
                          $fileSystem->copy($file, base_path($newFileName));
      Severity: Major
      Found in src/Console/ThemeGenerate.php and 2 other locations - About 1 hr to fix
      src/Console/ModulePublish.php on lines 57..62
      src/Console/ThemePublish.php on lines 55..60

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

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

                      if (is_dir($file)) {
                          $fileSystem->copyDirectory($file, public_path($newFileName));
                      } else {
                          @mkdir(public_path(str_replace(basename($newFileName), '', $newFileName)), 0755, true);
                          $fileSystem->copy($file, public_path($newFileName));
      Severity: Major
      Found in src/Console/ThemePublish.php and 2 other locations - About 1 hr to fix
      src/Console/ModulePublish.php on lines 57..62
      src/Console/ThemeGenerate.php on lines 50..55

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

      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 (isset($payload['hero_image'])) {
                  app(FileService::class)->delete($page->hero_image);
                  $file = request()->file('hero_image');
                  $path = app(FileService::class)->saveFile($file, 'public/images', [], true);
                  $payload['hero_image'] = $path['name'];
      Severity: Minor
      Found in src/Repositories/PageRepository.php and 1 other location - About 1 hr to fix
      src/Repositories/BlogRepository.php on lines 151..156

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

      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 (isset($payload['hero_image'])) {
                  app(FileService::class)->delete($blog->hero_image);
                  $file = request()->file('hero_image');
                  $path = app(FileService::class)->saveFile($file, 'public/images', [], true);
                  $payload['hero_image'] = $path['name'];
      Severity: Minor
      Found in src/Repositories/BlogRepository.php and 1 other location - About 1 hr to fix
      src/Repositories/PageRepository.php on lines 92..97

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

      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 asset has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          public function asset($encPath, $contentType, Filesystem $fileSystem)
          {
              try {
                  $path = CryptoServiceFacade::url_decode($encPath);
      
      
      Severity: Minor
      Found in src/Services/AssetService.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 saveFile has a Cognitive Complexity of 9 (exceeds 5 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 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 handle has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          public function handle()
          {
              $name = $this->argument('name');
      
              $fileSystem = new Filesystem();
      Severity: Minor
      Found in src/Console/ThemeGenerate.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 allTags has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function allTags()
          {
              $tags = [];
      
              if (app()->getLocale() !== config('cms.default-language', 'en')) {
      Severity: Minor
      Found in src/Repositories/BlogRepository.php - About 45 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 main has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function main()
          {
              if (!is_null(config('analytics.view_id')) && config('cms.analytics') == 'google') {
                  $period = Period::days(7);
      
      
      Severity: Minor
      Found in src/Controllers/DashboardController.php - About 45 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

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

          $('#saveImagesBtn').click(function(e){
              e.preventDefault();
              Dropzone.forElement('.dropzone').processQueue();
          });
      Severity: Minor
      Found in src/Assets/src/js/modules.js and 1 other location - About 40 mins to fix
      src/Assets/src/js/modules.js on lines 70..73

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

      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

          $('#saveFilesBtn').click(function(e){
              e.preventDefault();
              Dropzone.forElement('.dropzone').processQueue();
          });
      Severity: Minor
      Found in src/Assets/src/js/modules.js and 1 other location - About 40 mins to fix
      src/Assets/src/js/modules.js on lines 90..93

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

      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 inputsArray has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          private function inputsArray($jsonInput)
          {
              if ($jsonInput) {
                  $inputs = Input::json();
              } else {
      Severity: Minor
      Found in src/Services/ValidationService.php - About 35 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 update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function update($image, $input)
          {
              if (isset($input['location']) && !empty($input['location'])) {
                  $savedFile = app(FileService::class)->saveFile($input['location'], 'public/images', [], true);
      
      
      Severity: Minor
      Found in src/Repositories/ImageRepository.php - About 35 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 widget has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function widget($slug)
          {
              $widget = app(WidgetRepository::class)->getBySlug($slug);
      
              if ($widget) {
      Severity: Minor
      Found in src/Services/Traits/DefaultModuleServiceTrait.php - About 35 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 store has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public function store(Request $request)
          {
              try {
                  $validation = app(ValidationService::class)->check(['location' => 'required']);
                  if (!$validation['errors']) {
      Severity: Minor
      Found in src/Controllers/ImagesController.php - About 35 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