Showing 1,558 of 1,561 total issues
Method accountFollowingById
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function accountFollowingById(Request $request, $id)
{
abort_if(! $request->user() || ! $request->user()->token(), 403);
abort_unless($request->user()->tokenCan('read'), 403);
Function normalizeAudience
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public static function normalizeAudience($data, $localOnly = true)
{
if (! isset($data['to'])) {
return;
}
- Read upRead up
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 encode
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public static function encode(array $image, int $components_x = 4, int $components_y = 4, bool $linear = false): string {
if (($components_x < 1 || $components_x > 9) || ($components_y < 1 || $components_y > 9)) {
throw new InvalidArgumentException("x and y component counts must be between 1 and 9 inclusive.");
}
$height = count($image);
- Read upRead up
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 verifySignature
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
protected function verifySignature($headers, $payload)
{
$body = $this->payload;
$bodyDecoded = $payload;
$signature = is_array($headers['signature']) ? $headers['signature'][0] : $headers['signature'];
- Read upRead up
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 get
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function get(Status $status)
{
if($status->uri || $status->scope != 'public') {
return;
}
Method handle
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function handle()
{
$res = $this->activity;
$status = $this->status;
Method formStore
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function formStore(Request $request)
{
$this->validate($request, [
'report' => 'required|alpha_dash',
'type' => 'required|alpha_dash',
Method statusFavouritedBy
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function statusFavouritedBy(Request $request, $id)
{
abort_if(! $request->user() || ! $request->user()->token(), 403);
abort_unless($request->user()->tokenCan('read'), 403);
Method apiActivityLog
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function apiActivityLog(Request $request, $id)
{
$record = CuratedRegister::findOrFail($id);
$res = collect([
Method redirect
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function redirect(Request $request)
{
abort_unless((
config_cache('pixelfed.open_registration') &&
config('remote-auth.mastodon.enabled')
AccountController
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
class AccountController extends Controller
{
protected $filters = [
'user.mute',
'user.block',
Method statusReplies
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function statusReplies(Request $request, $id)
{
abort_if(! $request->user(), 403);
$this->validate($request, [
Method thread
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function thread(Request $request)
{
$this->validate($request, [
'pid' => 'required'
]);
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function blockedUsersUpdate(Request $request)
{
$this->validate($request, [
'profile_id' => 'required|integer|min:1',
]);
- Read upRead up
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 141.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function mutedUsersUpdate(Request $request)
{
$this->validate($request, [
'profile_id' => 'required|integer|min:1',
]);
- Read upRead up
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 141.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method settingsApiUpdateStorageType
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function settingsApiUpdateStorageType($request)
{
$this->validate($request, [
'primary_disk' => 'required|in:local,cloud',
'update_disk' => 'sometimes',
Method block
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function block(Request $request)
{
$this->validate($request, [
'type' => 'required|string|in:user',
'item' => 'required|integer|min:1',
Method statusRebloggedBy
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function statusRebloggedBy(Request $request, $id)
{
abort_if(! $request->user() || ! $request->user()->token(), 403);
abort_unless($request->user()->tokenCan('read'), 403);
Method handle
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function handle()
{
$this->info('Pixelfed Avatar Storage Manager');
$this->line(' ');
$segments = [
File AdminCuratedRegisterController.php
has 289 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace App\Http\Controllers;
use App\Mail\CuratedRegisterAcceptUser;