badgeteam/Hatchery

View on GitHub

Showing 35 of 536 total issues

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

    private function makeZip(string $filename, Version $version): void
    {
        $zip = new PharData(public_path($filename));

        foreach ($version->files as $file) {
Severity: Minor
Found in app/Jobs/PublishProject.php - About 1 hr to fix

    Function returnProjectView has a Cognitive Complexity of 10 (exceeds 5 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

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

        private function process(string $extension): void
        {
            if ($extension === 'v') {
                $badges = $this->file->version->project->badges()->whereNotNull('commands')->get();
                if ($badges->count() === 0) {
    Severity: Minor
    Found in app/Jobs/ProcessFile.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

    Avoid deeply nested control flow statements.
    Open

                        for (let p = 0; p < 8; p++) {
                            framebuffer[r][p] = document.getElementById('row' + r + 'pixel' + p);
                            if (!readOnly) {
                                framebuffer[r][p].onclick = function () {
                                    this.style.backgroundColor = document.getElementById('colour').style.backgroundColor;
    Severity: Major
    Found in resources/assets/js/app.js - About 45 mins to fix

      Method file has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              string $device,
              string $type,
              string $category,
              string $app,
              string $name
      Severity: Minor
      Found in app/Http/Controllers/MchController.php - About 35 mins to fix

        Function makeZip has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            private function makeZip(string $filename, Version $version): void
            {
                $zip = new PharData(public_path($filename));
        
                foreach ($version->files as $file) {
        Severity: Minor
        Found in app/Jobs/PublishProject.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 ensureWorkDirExists has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            private function ensureWorkDirExists(): void
            {
                $base = sys_get_temp_dir() . '/';
                $path = str_replace($base, '', $this->tempFolder);
                $dirs = explode('/', $path);
        Severity: Minor
        Found in app/Jobs/ProcessFile.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 addFiles has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function addFiles(string $dir, Version $version, $prefix = ''): void
            {
                $objects = scandir($dir);
                $objects = $objects ? array_diff($objects, ['.git', '.', '..']) : [];
                foreach ($objects as $object) {
        Severity: Minor
        Found in app/Support/Helpers.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 getScoreAttribute has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getScoreAttribute(): float
            {
                if ($this->votes === null || $this->votes->count() === 0) {
                    return 0;
                }
        Severity: Minor
        Found in app/Models/Project.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 up has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function up()
            {
                auth()->loginUsingId(1);
                foreach (Project::all() as $project) {
                    $version = $project->versions->last();

        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

        Avoid too many return statements within this method.
        Open

                return redirect()->route('projects.index')->withSuccesses([$project->name . ' being imported!']);
        Severity: Major
        Found in app/Http/Controllers/ProjectsController.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return redirect()
                      ->route('projects.edit', ['project' => $file->version->project])
                      ->withSuccesses([$file->name . ' saved']);
          Severity: Major
          Found in app/Http/Controllers/FilesController.php - About 30 mins to fix

            Function execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                private function execute(string $command): int
                {
                    $stdOut = $stdErr = '';
                    $returnValue = 255;
                    $fds = [
            Severity: Minor
            Found in app/Jobs/ProcessFile.php - About 25 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 6 (exceeds 5 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 25 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 getDescriptionAttribute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getDescriptionAttribute(): ?string
                {
                    $full = true;
                    $request = request();
                    if ($request->has('description') && $request->description === false) {
            Severity: Minor
            Found in app/Models/Project.php - About 25 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