pbbg/topsite

View on GitHub

Showing 6 of 10 total issues

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

    public function vote(VoteIn $in, String $slug): RedirectResponse
    {
        $listing = Game::findBySlug($slug);

        // @todo move this to a job because it takes a few seconds to work if it fails
Severity: Minor
Found in app/Http/Controllers/ListingController.php - About 1 hr to fix

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

        public function rules()
        {
            return [
                'name'  =>  [
                    'required',
    Severity: Minor
    Found in app/Http/Requests/CreateGameRequest.php - About 1 hr to fix

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

          public function update(CreateGameRequest $request, Game $game, ImageService $imageService): RedirectResponse
          {
              $category = Category::findBySlug($request->input('category_id'));
      
              $game->fill($request->all('name', 'url', 'description', 'category_id', 'callback_url'));
      Severity: Minor
      Found in app/Http/Controllers/GameController.php - About 1 hr to fix

        Function number_format has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        function number_format(number, decimals, dec_point, thousands_sep) {
            // *     example: number_format(1234.56, 2, ',', ' ');
            // *     return: '1 234,56'
            number = (number + '').replace(',', '').replace(' ', '');
            var n = !isFinite(+number) ? 0 : +number,
        Severity: Minor
        Found in resources/js/helpers.js - 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 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function handle($request, Closure $next)
            {
        
                if (Settings::where('key', 'site_online')->first()->value !== '1') {
                    if ($request->user() && $request->user()->isAdmin()) {
        Severity: Minor
        Found in app/Http/Middleware/CheckSiteIsOnline.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(CreateGameRequest $request, Game $game, ImageService $imageService): RedirectResponse
            {
                $category = Category::findBySlug($request->input('category_id'));
        
                $game->fill($request->all('name', 'url', 'description', 'category_id', 'callback_url'));
        Severity: Minor
        Found in app/Http/Controllers/GameController.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