Showing 109 of 109 total issues
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 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");
Similar blocks of code found in 2 locations. Consider refactoring. Open
Privly.message[test.action]({
name: test.action,
action: 'ping',
data: $('[name="data"]').val()
}, true).then(appendPongResponse);
- 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 59.
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
Privly.message[test.action]({
name: test.action,
action: 'pingAsync',
data: $('[name="data"]').val()
}, true).then(appendPongResponse);
- 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 59.
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 start
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
SeamlessAdapter.prototype.start = function () {
var self = this;
if (self.started) {
return;
}
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");
Similar blocks of code found in 2 locations. Consider refactoring. Open
privlyNetworkService.initPrivlyService(
privlyNetworkService.contentServerDomain(),
self.onConnectionCheckSucceeded.bind(self),
self.onConnectionCheckFailed.bind(self),
self.onConnectionCheckFailed.bind(self)
- 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 57.
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
privlyNetworkService.initPrivlyService(
privlyNetworkService.contentServerDomain(),
self.connectionSucceeded.bind(self),
self.connectionFailed.bind(self),
self.connectionFailed.bind(self)
- 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 57.
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 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 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 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 _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 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 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"