Showing 7,873 of 7,873 total issues
Function afterSave
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function afterSave() {
$adminGroup = $this->modx->getObject('modUserGroup', array('name' => 'Administrator'));
if ($adminGroup && $this->object->get('principal') !== $adminGroup->get('id')) {
$adminContextPolicy = $this->modx->getObject('modAccessPolicy',array('name' => 'Context'));
if ($adminContextPolicy) {
- 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 setUsersIn
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function setUsersIn() {
$users = $this->getProperty('users');
$memberships = array();
if (!empty($users)) {
$users = is_array($users) ? $users : $this->modx->fromJSON($users);
- 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 remove
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function remove(array $ancestors = array()) {
if ($this->xpdo instanceof modX) {
$this->xpdo->invokeEvent('OnCategoryBeforeRemove',array(
'category' => &$this,
'ancestors' => $ancestors,
- 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
Avoid deeply nested control flow statements. Open
if ($state == xPDOTransport::STATE_PACKED) {
$this->set('state', xPDOTransport::STATE_UNPACKED);
}
Avoid deeply nested control flow statements. Open
if ($filename != '.' && $filename != '..' && $filename != '.svn' && $filename != '.git' && in_array($extension,$this->patterns)) {
$file= $path . $filename;
if (!is_dir($file)) {
$this->files[]= $file;
}
Function fetchform
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function fetchform($URI)
{
if ($this->fetch($URI) !== false) {
- 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 prepareRow
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function prepareRow(xPDOObject $object) {
$objectArray = $object->toArray();
if (empty($objectArray['name'])) $objectArray['name'] = '('.$this->modx->lexicon('none').')';
$objectArray['authority_name'] = !empty($objectArray['role_name']) ? $objectArray['role_name'].' - '.$objectArray['authority'] : $objectArray['authority'];
- 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 isMember
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function isMember($groups,$matchAll = false) {
$isMember= false;
$groupNames= $this->getUserGroupNames();
if ($groupNames) {
if (is_array($groups)) {
- 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 getUserGroups
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function getUserGroups() {
$groups= array();
$id = $this->get('id') ? (string) $this->get('id') : '0';
if (isset($_SESSION["modx.user.{$id}.userGroups"]) && $this->xpdo->user->get('id') == $this->get('id')) {
$groups= $_SESSION["modx.user.{$id}.userGroups"];
- 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 beforeSet
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function beforeSet() {
$policyId = $this->getProperty('policy');
$principalId = $this->getProperty('principal');
$target = $this->getProperty('target');
- 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 validate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function validate() {
$oldPassword = $this->getProperty('password_old');
$newPassword = $this->getProperty('password_new');
$confirmPassword = $this->getProperty('password_confirm');
- 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 checkUsername
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function checkUsername() {
$username = $this->processor->getProperty('username');
if (empty($username)) {
$this->processor->addFieldError('username',$this->modx->lexicon('user_err_not_specified_username'));
} elseif (!preg_match('/^[^\'\\x3c\\x3e\\(\\);\\x22]+$/', $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
Avoid deeply nested control flow statements. Open
if ($key === reset($msgs)) {
$this->_setRaw('password', $this->get('cachepwd'));
$this->_setRaw('cachepwd', '');
$activated = $this->save();
}
Function getProperties
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function getProperties($properties = null) {
$this->xpdo->getParser();
$this->_properties= $this->xpdo->parser->parseProperties($this->get('properties'));
$set= $this->getPropertySet();
if (!empty($set)) {
- 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 fetchtext
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function fetchtext($URI)
{
if ($this->fetch($URI) !== false) {
if (is_array($this->results)) {
for ($x = 0; $x < count($this->results); $x++)
- 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 resolveDependency
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function resolveDependency($package, $constraint) {
$resolved = false;
/** @var modTransportProvider|null $provider */
$provider = null;
$resolution = $this->findResolution($package, $constraint, $provider);
- 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 getUserGroupNames
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function getUserGroupNames() {
$groupNames= array();
$id = $this->get('id') ? (string) $this->get('id') : '0';
if (isset($_SESSION["modx.user.{$id}.userGroupNames"]) && $this->xpdo->user->get('id') == $this->get('id')) {
$groupNames= $_SESSION["modx.user.{$id}.userGroupNames"];
- 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 _httprequest
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function _httprequest($url, $fp, $URI, $http_method, $content_type = "", $body = "")
Function set
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function set($k, $v= null, $vType= '') {
if (in_array($k, array('snippet', 'plugincode', 'content'))) {
$v= trim($v);
if (strncmp($v, '<?', 2) == 0) {
$v= substr($v, 2);
- 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 addEmbeddedImage
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
$path,
$cid,
$name = '',
$encoding = self::ENCODING_BASE64,
$type = '',