Showing 1,559 of 1,562 total issues
Method discoverAccountsPopular
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function discoverAccountsPopular(Request $request)
{
abort_if(! $request->user(), 403);
$pid = $request->user()->profile_id;
Method store
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function store(Request $request)
{
$this->validate($request, [
'item' => 'required|integer|min:1',
]);
Method conciergeStore
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function conciergeStore(Request $request)
{
abort_if($request->user(), 404);
$rules = [
'sid' => 'required_if:action,email|integer|min:1|max:20000000',
Method mediaSettings
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function mediaSettings()
{
$this->line('');
$this->info('Media Settings:');
$optimize_media = $this->choice('Optimize media uploads? Requires jpegoptim and other dependencies!', ['false', 'true'], 1);
Method installerSteps
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function installerSteps()
{
$this->envCheck();
$this->envCreate();
$this->installType();
Method handle
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function handle(): void
{
$sid = $this->sid;
$status = StatusService::get($sid, false);
Method likedBy
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function likedBy($status)
{
$empty = [
'username' => null,
'others' => false
Method get
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function get($aid, $tid)
{
$actor = AccountService::get($aid, true);
$target = AccountService::get($tid, true);
if(!$actor || !$target) {
Method warmCache
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function warmCache($force = false, $limit = 100)
{
if(self::count() == 0 || $force == true) {
$hideNsfw = config('instance.hide_nsfw_on_public_feeds');
Redis::del(self::CACHE_KEY);
Method getCollection
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getCollection($id)
{
$collection = Cache::remember(self::CACHE_KEY . 'get:' . $id, 86400, function() use($id) {
$collection = Collection::find($id);
if(!$collection) {
Method privateAccountOptions
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function privateAccountOptions(Request $request)
{
$this->validate($request, [
'mode' => 'required|string|in:keep-all,mutual-only,only-followers,remove-all',
'duration' => 'required|integer|min:60|max:525600',
Method deleteId
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function deleteId(Request $request)
{
abort_if(!$request->user(), 403);
$this->validate($request, [
'collection_id' => 'required|int|min:1|exists:collections,id',
Method transform
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function transform(Status $status)
{
return [
'id' => (string) $status->id,
'created_at' => $status->created_at->toJSON(),
Method sponsorStore
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function sponsorStore(Request $request)
{
$this->validate($request, [
'patreon' => 'nullable|string',
'liberapay' => 'nullable|string',
Method relistInstance
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function relistInstance()
{
$id = search(
'Search by domain',
fn (string $value) => strlen($value) > 0
Method unlistInstance
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function unlistInstance()
{
$id = search(
'Search by domain',
fn (string $value) => strlen($value) > 0
Method unbanInstance
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function unbanInstance()
{
$id = search(
'Search by domain',
fn (string $value) => strlen($value) > 0
Method refetchRemoteAvatars
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function refetchRemoteAvatars()
{
if(!$this->confirm('Are you sure you want to refetch all remote avatars? This could take a while.')) {
return;
}
Method banInstance
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function banInstance()
{
$id = search(
'Search by domain',
fn (string $value) => strlen($value) > 0
Similar blocks of code found in 2 locations. Consider refactoring. Open
<?php
namespace App\Events\LiveStream;
use Illuminate\Broadcasting\Channel;
- 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 106.
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