Showing 1,558 of 1,561 total issues
Method comment
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function comment(Request $request)
{
abort_if(! (bool) config_cache('instance.stories.enabled') || ! $request->user(), 404);
$this->validate($request, [
'sid' => 'required',
Function getMaxMastodon
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public static function getMaxMastodon($id = false, $start = 0, $limit = 10)
{
$ids = self::getRankedMaxId($id, $start, $limit);
if (empty($ids)) {
- 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 updateUrls
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
protected function updateUrls()
{
$this->info('Updating urls...');
$oldDomain = trim($this->argument('oldDomain'));
$newDomain = trim($this->argument('newDomain'));
- 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
File AdminUserController.php
has 267 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace App\Http\Controllers\Admin;
use Cache, DB;
File ImportPostController.php
has 267 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
Method settingsApiUpdatePlatformType
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function settingsApiUpdatePlatformType($request)
{
$this->validate($request, [
'allow_app_registration' => 'required',
'app_registration_rate_limit_attempts' => 'required|integer|min:1',
Method comment
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function comment(Request $request)
{
abort_if(! (bool) config_cache('instance.stories.enabled') || ! $request->user(), 404);
$this->validate($request, [
'sid' => 'required',
File home.blade.php
has 266 lines of code (exceeds 250 allowed). Consider refactoring. Open
@extends('admin.partial.template-full')
@section('section')
<div class="title d-flex justify-content-between align-items-center">
<h3 class="font-weight-bold">Users</h3>
Method handleFollowActivity
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function handleFollowActivity()
{
$actor = $this->actorFirstOrCreate($this->payload['actor']);
$target = $this->actorFirstOrCreate($this->payload['object']);
if(!$actor || !$target) {
Method getInstancesApi
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getInstancesApi(Request $request)
{
$this->validate($request, [
'filter' => [
'nullable',
Method transform
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function transform(Profile $profile)
{
if (! $profile) {
return [];
}
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function apiV1Delete(Request $request, $id)
{
abort_if(! (bool) config_cache('instance.stories.enabled') || ! $request->user(), 404);
$user = $request->user();
- 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 128.
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 delete(Request $request, $id)
{
abort_if(! (bool) config_cache('instance.stories.enabled') || ! $request->user(), 404);
$user = $request->user();
- 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 128.
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
Helpers
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class Helpers
{
public static function validateObject($data)
{
$verbs = ['Create', 'Announce', 'Like', 'Follow', 'Delete', 'Accept', 'Reject', 'Undo', 'Tombstone'];
Method handle
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function handle()
{
$id = $this->profileId;
if(Cache::has(FollowerService::FOLLOWERS_SYNC_KEY . $id) && Cache::has(FollowerService::FOLLOWING_SYNC_KEY . $id)) {
Method remoteToCloud
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function remoteToCloud($media)
{
$url = $media->remote_url;
if (! Helpers::validateUrl($url)) {
Method unlinkRemoveMedia
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function unlinkRemoveMedia($status)
{
Media::whereStatusId($status->id)
->get()
->each(function ($media) {
Method get
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function get($domain)
{
$version = config('pixelfed.version');
$appUrl = config('app.url');
$headers = [
Method delete
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function delete(Request $request)
{
$this->authCheck();
$this->validate($request, [
Method homeUpdate
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function homeUpdate(Request $request)
{
$this->validate($request, [
'name' => 'nullable|string|max:'.config('pixelfed.max_name_length'),
'bio' => 'nullable|string|max:'.config('pixelfed.max_bio_length'),