Showing 48 of 109 total issues
Function click
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
click: function(evt, callback) {
if( ! privlyNetworkService.permissions.canUpdate ) {
callbacks.singleClick(evt, callback);
return;
- 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 updateLink
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
SeamlessAdapter.prototype.updateLink = function () {
var self = this;
if (self.privlyUrl === null) {
return Promise.resolve();
Function SeamlessAdapter
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
var SeamlessAdapter = function (application, options) {
/**
* The Privly URL that is created to insert to the editable element.
*
* @type {String}
Function saveWhitelist
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function saveWhitelist() {
var url_inputs = document.getElementsByClassName('whitelist_url');
var domains = []; // Stores whitelist inputs and whitelisted values
var input_fields = [];
Function start
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
SeamlessAdapter.prototype.start = function () {
var self = this;
if (self.started) {
return;
}
Function initializeNavigation
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
initializeNavigation: function() {
var domain = privlyNetworkService.contentServerDomain();
$(".home_domain").text(domain.split("/")[2]);
$(".account_url").attr("href", domain + "/pages/account");
$(".legal_nav").attr("href", domain + "/pages/privacy");
Function parseDate
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
parseDate: function(string, mode) {
var date = new Date(string);
var current = new Date();
Function loadLink
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
SeamlessAdapter.prototype.loadLink = function (link) {
var self = this;
var url = privlyParameters.getApplicationUrl(link);
var reqUrl = privlyParameters.getParameterHash(url).privlyDataURL;
Function restoreServer
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function restoreServer(){
var posting_content_server_url = Privly.options.getServerUrl();
var server_input = document.getElementById("content_server_url");
Function getItem
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
getItem: function(key) {
if ( ls.localStorageDefined ) {
var value = localStorage.getItem(key);
if (value === null){
return undefined;
- 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 getParameterHash
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
getParameterHash: function(url)
{
var parameters = {};
var hashIndex = url.indexOf("#");
if (hashIndex >= 0) {
- 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 platformName
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
platformName: function() {
if (navigator.userAgent.indexOf("iPhone") >= 0 ||
navigator.userAgent.indexOf("iPad") >= 0) {
if( navigator.userAgent.indexOf("Safari") >= 0 ) { return "HOSTED"; }
return "IOS";
- 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 sendMessageTo
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
SafariAdapter.prototype.sendMessageTo = function (to, payload) {
if (to === 'BACKGROUND_SCRIPT') {
if (this.getContextName() === 'BACKGROUND_SCRIPT') {
safari.self.contentWindow.postMessage(payload, '*');
}
Function sendMessageTo
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
FirefoxAdapter.prototype.sendMessageTo = function (to, data) {
var contextName = this.getContextName();
// Messages from Privly Applications to Background Script, Content Scripts
// Privly Applications can't send messages directly to background scripts, they do so via
Function processResponseContent
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function processResponseContent(response) {
// Change the edit button back to the default style
// if it has been modified. This is usually for
// when the user has edited content and submitted
Function _postCompleted
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
NewAdapter.prototype._postCompleted = function (response, url) {
$("#save").prop('disabled', false);
if (response.jqXHR.status === 201 && url !== undefined && url !== "") {
Privly.message.messageExtension({privlyUrl: url});
Function setListener
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
SafariAdapter.prototype.setListener = function (callback) {
if (this.getContextName() === 'BACKGROUND_SCRIPT') {
safari.application.addEventListener("message", function(payload) {
if (typeof payload.name !== "undefined" && payload.name === "privlyMessage") {
// The message is received from other than BACKGROUND_SCRIPT
Function showDownloadMessage
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
showDownloadMessage: function(callback) {
// Show the download extension link in the hosted context
if( privlyNetworkService.platformName() === "HOSTED" && !privlyHostPage.isInjected() ){
- 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 not is_build_target(template):
continue
Avoid deeply nested control flow statements. Open
for(var i=0 ; i<len ; i++) {
this.workers[i].port.emit("PRIVLY_MESSAGE", data);
}