badgeteam/Hatchery

View on GitHub

Showing 35 of 536 total issues

Function onload has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

window.onload = function () {
    const ext = document.getElementById('extension');
    let langmode = 'python';
    if (ext) {
        if (ext.getAttribute('value') === 'json') {
Severity: Minor
Found in resources/assets/js/app.js - About 6 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

Function onload has 155 lines of code (exceeds 25 allowed). Consider refactoring.
Open

window.onload = function () {
    const ext = document.getElementById('extension');
    let langmode = 'python';
    if (ext) {
        if (ext.getAttribute('value') === 'json') {
Severity: Major
Found in resources/assets/js/app.js - About 6 hrs to fix

    File illustrated-layout.blade.php has 388 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <!DOCTYPE html>
    <html lang="en">
        <head>
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    Severity: Minor
    Found in resources/views/errors/illustrated-layout.blade.php - About 5 hrs to fix

      Project has 30 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Project extends Model
      {
          use SoftDeletes;
          use HasFactory;
      
      
      Severity: Minor
      Found in app/Models/Project.php - About 3 hrs to fix

        File ProjectsController.php has 310 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        declare(strict_types=1);
        
        namespace App\Http\Controllers;
        Severity: Minor
        Found in app/Http/Controllers/ProjectsController.php - About 3 hrs to fix

          File Project.php has 300 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          declare(strict_types=1);
          
          namespace App\Models;
          Severity: Minor
          Found in app/Models/Project.php - About 3 hrs to fix

            File app.js has 298 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /* global require */
            
            /**
             * First we will load all of this project's JavaScript dependencies which
             * includes Vue and other libraries. It is a great starting point when
            Severity: Minor
            Found in resources/assets/js/app.js - About 3 hrs to fix

              ProjectsController has 23 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class ProjectsController extends Controller
              {
                  /**
                   * Create a new controller instance.
                   */
              Severity: Minor
              Found in app/Http/Controllers/ProjectsController.php - About 2 hrs to fix

                Function pixelToHexA has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                window.pixelToHexA = function (rgba) {
                    let remove = 5;
                    if (rgba.indexOf('rgba') === -1) {
                        remove = 4;
                    }
                Severity: Minor
                Found in resources/assets/js/app.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

                File PublicController.php has 257 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                
                declare(strict_types=1);
                
                namespace App\Http\Controllers;
                Severity: Minor
                Found in app/Http/Controllers/PublicController.php - About 2 hrs to fix

                  Function pixelToHexA has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  window.pixelToHexA = function (rgba) {
                      let remove = 5;
                      if (rgba.indexOf('rgba') === -1) {
                          remove = 4;
                      }
                  Severity: Minor
                  Found in resources/assets/js/app.js - About 1 hr to fix

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

                        private function returnProjectView(Request $request, $projects, string $badge = '')
                        {
                            $category = '';
                            if ($request->has('category')) {
                                $category = Category::where('slug', $request->get('category'))->firstOrFail();
                    Severity: Minor
                    Found in app/Http/Controllers/PublicController.php - About 1 hr to fix

                      Method app has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function app(string $device, string $type, string $category, string $app): JsonResponse
                          {
                              /** @var Badge $badge */
                              $badge = Badge::whereSlug($device)->firstOrFail();
                              $categoryId = Category::whereSlug($category)->firstOrFail()->id;
                      Severity: Minor
                      Found in app/Http/Controllers/MchController.php - About 1 hr to fix

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

                            private function manageBadges(Project $project, Request $request): void
                            {
                                if ($request->has('badge_ids')) {
                                    $project->badges()->detach();
                                    $badges = Badge::find($request->get('badge_ids'));
                        Severity: Minor
                        Found in app/Http/Controllers/ProjectsController.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 33 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function handle()
                            {
                                $sitemap = Sitemap::create()
                                    ->add(
                                        Url::create('/')
                        Severity: Minor
                        Found in app/Console/Commands/GenerateSitemap.php - About 1 hr to fix

                          Method execute has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private function execute(string $command): int
                              {
                                  $stdOut = $stdErr = '';
                                  $returnValue = 255;
                                  $fds = [
                          Severity: Minor
                          Found in app/Jobs/ProcessFile.php - About 1 hr to fix

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

                                public static function boot(): void
                                {
                                    parent::boot();
                            
                                    static::creating(
                            Severity: Minor
                            Found in app/Models/Project.php - About 1 hr to fix

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

                                  public function handle(Git $git)
                                  {
                                      $version = $this->project->getUnpublishedVersion();
                              
                                      try {
                              Severity: Minor
                              Found in app/Jobs/UpdateProject.php - About 1 hr to fix

                                Method projectJson has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public function projectJson(string $slug): JsonResponse
                                    {
                                        /** @var Project|null $project */
                                        $project = Project::where('slug', $slug)->first();
                                        if ($project === null) {
                                Severity: Minor
                                Found in app/Http/Controllers/PublicController.php - About 1 hr to fix

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

                                      public function update(FileUpdateRequest $request, File $file): RedirectResponse
                                      {
                                          try {
                                              $file->content = $request->file_content;
                                              $file->save();
                                  Severity: Minor
                                  Found in app/Http/Controllers/FilesController.php - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language