Showing 4,504 of 4,504 total issues
Function groupCreateChecks
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected function groupCreateChecks(\OCP\Share\IShare $share) {
// Verify group shares are allowed
if (!$this->allowGroupSharing()) {
throw new \Exception('Group sharing is not allowed');
}
- 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 getMessageForLicense
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function getMessageForLicense(array $info, string $language = null): array {
$l = $this->l10nFactory->get('core', $language);
// check if present
if ($info['licenseState'] === ILicenseManager::LICENSE_STATE_MISSING) {
- 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 moveAvatars
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function moveAvatars(IOutput $out, IUser $user) {
$userId = $user->getUID();
try {
\OC\Files\Filesystem::initMountPoints($userId);
- 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 getLicenseWithState
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function getLicenseWithState(string $appid) {
// check if license is missing
$licenseObj = $this->licenseFetcher->getOwncloudLicense();
if ($licenseObj === null) {
$licenseState = ILicenseManager::LICENSE_STATE_MISSING;
- 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 rmdirr
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static function rmdirr($dir, $deleteSelf = true) {
if (\is_dir($dir)) {
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST
- 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 getSupportedDatabases
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function getSupportedDatabases($allowAllDatabases = false) {
$availableDatabases = [
'sqlite' => [
'type' => 'class',
'call' => 'SQLite3',
- 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 saveColumn
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private static function saveColumn($column, $xml) {
$xml->addChild('name', $column->getName());
switch ($column->getType()) {
case 'SmallInt':
case 'Integer':
- 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 addExternalResource
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private static function addExternalResource($application, $prepend, $path, $type = "script") {
if ($type === "style") {
if (!\in_array($path, self::$styles)) {
if ($prepend === true) {
\array_unshift(self::$styles, $path);
- 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 verifyAuthHeaders
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function verifyAuthHeaders($request) {
$shallLogout = false;
try {
$lastUser = null;
foreach ($this->getAuthModules(true) as $module) {
- 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 validateInput
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected function validateInput(InputInterface $input, OutputInterface $output, $supportedDatabases) {
$db = \strtolower($input->getOption('database'));
if (!\in_array($db, $supportedDatabases)) {
throw new InvalidArgumentException("Database <$db> is not supported.");
- 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 __construct
has 14 arguments (exceeds 4 allowed). Consider refactoring. Open
$appName,
IRequest $request,
IURLGenerator $urlGenerator,
IUserManager $userManager,
OC_Defaults $defaults,
Similar blocks of code found in 2 locations. Consider refactoring. Open
$('#pass2').strengthify({
zxcvbn: OC.linkTo('core','vendor/zxcvbn/dist/zxcvbn.js'),
titles: [
t('settings', 'Very weak password'),
t('settings', 'Weak password'),
- 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 70.
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
$('#adminpass').strengthify({
zxcvbn: OC.linkTo('core','vendor/zxcvbn/dist/zxcvbn.js'),
titles: [
t('core', 'Very weak password'),
t('core', 'Weak password'),
- 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 70.
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
Function rebuildNavigation
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
rebuildNavigation: function() {
$.getJSON(OC.filePath('settings', 'ajax', 'navigationdetect.php')).done(function(response){
if(response.status === 'success'){
var idsToKeep = {};
var navEntries=response.nav_entries;
Function _initFilterField
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
_initFilterField: function ($container) {
this.$filterField = $('<input type="hidden" name="tags"/>');
$container.append(this.$filterField);
this.$filterField.select2({
placeholder: t('systemtags', 'Select tags to filter by'),
Function getAuthUrl
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
OCA.External.Settings.OAuth2.getAuthUrl = function (backendUrl, data) {
var $tr = data['tr'];
var configured = $tr.find('[data-parameter="configured"]');
var token = $tr.find('.configuration [data-parameter="token"]');
Function EventSource
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
OC.EventSource=function(src,data){
var dataStr='';
var name;
var joinChar;
this.typelessListeners=[];
Function showNotification
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
showNotification: function() {
if (!this._template) {
this._template = Handlebars.compile(this.NOTIFICATION_TEMPLATE);
}
Function davSync
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
function davSync(method, model, options) {
var params = {type: getTypeForMethod(method, model)};
var isCollection = (model instanceof Backbone.Collection);
// Ensure that we have a URL.
Method setDisplayName
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setDisplayName($username, $displayName) {
$resp = $this->validateString($displayName, 64);
if ($resp) {
return $resp;
}