Showing 34 of 34 total issues
Function handleFormData
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
async function handleFormData() {
sanitizeInput();
// If user typed new password, username or URL the token is likely not valid any more
- 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 updateCapabilities
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
async updateCapabilities() {
const data = await this._doApiCall(apiUrlCapabilities);
if (!data._failed && data.capabilities) {
// Don't test data.capabilities.files_sharing.api_enabled because the next line contains it all
// Is public sharing enabled?
- 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 handleFormData
has 102 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function handleFormData() {
sanitizeInput();
// If user typed new password, username or URL the token is likely not valid any more
File cloudconnection.js
has 331 lines of code (exceeds 250 allowed). Consider refactoring. Open
//#region Configurable options and useful constants
const apiUrlBase = "ocs/v1.php";
const apiUrlUserInfo = "/cloud/users/";
const apiUrlUserID = "/cloud/user";
const apiUrlShares = "/apps/files_sharing/api/v1/shares";
Similar blocks of code found in 2 locations. Consider refactoring. Open
try {
const u = new URL(data.capabilities.password_policy.api.validate);
if (u.host === (new URL(this.serverUrl)).host) {
this._password_validate_url = u.origin + u.pathname;
}
- 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 93.
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
try {
const u = new URL(data.capabilities.password_policy.api.generate);
if (u.host === (new URL(this.serverUrl)).host) {
this._password_generate_url = u.origin + u.pathname;
}
- 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 93.
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
File management.js
has 268 lines of code (exceeds 250 allowed). Consider refactoring. Open
const accountId = new URL(location.href).searchParams.get("accountId");
const ncc = new CloudConnection(accountId);
loadFormData()
.then(updateHeader)
Function updateCapabilities
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
async updateCapabilities() {
const data = await this._doApiCall(apiUrlCapabilities);
if (!data._failed && data.capabilities) {
// Don't test data.capabilities.files_sharing.api_enabled because the next line contains it all
// Is public sharing enabled?
Function updateCloudInfo
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function updateCloudInfo() {
let answer = await ncc.updateUserId();
ncc.laststatus = null;
if (answer._failed) {
// If login failed, we might be using an app token which requires a lowercase user name
Function updateFreeSpaceInfo
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
async updateFreeSpaceInfo() {
let spaceRemaining = -1;
let spaceUsed = -1;
const data = await this._doApiCall(apiUrlUserInfo + this.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 showErrors
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function showErrors() {
if (ncc.laststatus) {
popup.error(ncc.laststatus);
} else if (false === ncc.public_shares_enabled) {
popup.error('sharing_off');
- 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 updateStatusDisplay
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function updateStatusDisplay(uploads) {
// Remove extra rows
while (status_lines.rows.length > uploads.size) {
status_lines.deleteRow(-1);
}
- 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 _doApiCall
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
async _doApiCall(suburl, method = 'GET', additional_headers = undefined, body = undefined) {
let url;
if (suburl.startsWith(this.serverUrl)) {
url = suburl;
} else {
Function _doUpload
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
async _doUpload(uploadId, fileName, fileObject) {
// Is the file bigger than the maximum size for WebDAV?
attachmentStatus.get(uploadId).set_status('checkingsize');
if (fileObject.size > DAV_MAX_FILE_SIZE) {
attachmentStatus.get(uploadId).fail();
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ("free" in data.quota) {
const free = parseInt(data.quota.free);
spaceRemaining = free >= 0 && free <= Number.MAX_SAFE_INTEGER ? free : -1;
}
- 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 65.
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
if ("used" in data.quota) {
const used = parseInt(data.quota.used);
spaceUsed = used >= 0 && used <= Number.MAX_SAFE_INTEGER ? used : -1;
}
- 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 65.
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 _doUpload
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
async _doUpload(uploadId, fileName, fileObject) {
// Is the file bigger than the maximum size for WebDAV?
attachmentStatus.get(uploadId).set_status('checkingsize');
if (fileObject.size > DAV_MAX_FILE_SIZE) {
attachmentStatus.get(uploadId).fail();
- 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 _doApiCall
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
async _doApiCall(suburl, method = 'GET', additional_headers = undefined, body = undefined) {
let url;
if (suburl.startsWith(this.serverUrl)) {
url = suburl;
} else {
- 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 fill_status_row
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function fill_status_row(status, row) {
status_lines.rows[row].cells[0].textContent = status.filename;
const status_cell = status_lines.rows[row].cells[1];
if (status.error) {
- 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 updateGauge
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function updateGauge() {
freespaceGauge.style.visibility = "hidden";
// Only show gauge if relevant form data match the account data
if (username.value === ncc.username && serverUrl.value === ncc.serverUrl) {
let theAccount = await messenger.cloudFile.getAccount(accountId);