Showing 59 of 66 total issues
Method login
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function login(Request $request, Response $response): Response
{
/** @var ValidationHelper $validator */
$validator = make(ValidationHelper::class);
Method home
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function home(Request $request, Response $response, int $page = 0): Response
{
$page = max(0, --$page);
switch (param($request, 'sort', 'time')) {
Method streamMedia
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function streamMedia(
Request $request,
Response $response,
Filesystem $storage,
$media,
Method ldapConnect
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function ldapConnect()
{
if (!extension_loaded('ldap')) {
$this->logger->error('The LDAP extension is not loaded.');
return false;
Method runWithDbSort
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function runWithDbSort(int $page): MediaRepository
{
$params = [];
if ($this->isAdmin) {
[$queryMedia, $queryPages] = $this->buildAdminQueries();
Method getLdapRdn
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function getLdapRdn(string $username, $server)
{
//Dynamic LDAP User Binding
if (@is_string($this->config['ldap']['search_filter'])) {
//Replace ???? with username
Method handlePartialRequest
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function handlePartialRequest(
Response $response,
Stream $stream,
string $range,
string $disposition,
Function publishToggle
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
publishToggle: function () {
var id = $(this).data('id');
var $callerButton = $(this);
var isOutline = false;
if ($(this).data('published')) {
Method saveMedia
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function saveMedia(Response $response, UploadedFileInterface $file, $user, $code)
{
if ($code === null) {
do {
$code = humanRandomString();
Method mime2font
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function mime2font($mime)
{
$classes = [
'image' => 'fa-file-image',
'audio' => 'fa-file-audio',
Method recoverMail
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function recoverMail(Request $request, Response $response): Response
{
if ($this->session->get('logged', false)) {
return redirect($response, route('home'));
}
Function saveTag
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
saveTag: function () {
var tag = $(this).val();
var mediaId = $(this).data('id');
var $parent = $(this).parent();
if (tag === '') {
Function login
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
public function login(Request $request, Response $response): Response
{
/** @var ValidationHelper $validator */
$validator = make(ValidationHelper::class);
- 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 getLdapRdn
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
protected function getLdapRdn(string $username, $server)
{
//Dynamic LDAP User Binding
if (@is_string($this->config['ldap']['search_filter'])) {
//Replace ???? with username
- 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 createAppInstance
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static function createAppInstance(Container $container)
{
$config = $container->get('config');
$loader = new FilesystemLoader(BASE_DIR.'resources/templates');
Method sendCreateNotification
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function sendCreateNotification($request, $resetToken = null)
{
if ($resetToken === null && !empty(param($request, 'password'))) {
$message = lang('mail.new_account_text_with_pw', [
param($request, 'username'),
Method checkForUpdates
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function checkForUpdates(Request $request, Response $response): Response
{
$jsonResponse = [
'status' => 'OK',
'message' => lang('already_latest_version'),
Function addTag
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
addTag: function (e) {
var $caller = $(this);
var $newAddTag = $caller.clone()
.click(app.addTag)
.appendTo($caller.parent());
Method __construct
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function __construct(string $name, $path = '')
{
if (session_status() === PHP_SESSION_NONE) {
if (!is_writable($path) && $path !== '') {
throw new Exception("The given path '{$path}' is not writable.");
Method getString
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function getString($key, $lang, $args): string
{
$redLang = strtolower(substr($lang, 0, 2));
if (array_key_exists($lang, $this->cache)) {