Showing 49 of 55 total issues
File tradable.js
has 1939 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
// Avoid console errors when not supported
if (typeof console === "undefined" || typeof console.log !== "function" || typeof console.warn !== "function" || typeof console.error !== "function") {
console = { log: function() {}, warn: function() {}, error: function() {} };
}
Function makeOsRequest
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
makeOsRequest : function (reqType, type, accountId, method, postData, resolve, reject){
var version = (reqType === "internal") ? "" : "v1/";
var endpoint;
if(reqType === tradable.TWO_FACTOR_AUTH) {
endpoint = postData.endpointURL;
Function searchInstrumentsForAccount
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
searchInstrumentsForAccount : function (accountId, query, resolve, reject){
var deferred = new $.Deferred();
if(isFullInstrumentListAvailableForAccount(accountId)) {
var instrumentsDeferred = new $.Deferred();
Function startCandleUpdates
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
startCandleUpdates : function(instrumentId, from, aggregation, callback) {
tradable.stopCandleUpdates();
var aggregationInMillis = aggregation * 60 * 1000;
tradable.subscribedCandleId = instrumentId;
Function initializeLibrary
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function initializeLibrary(){
var success = false;
var opener = window.opener;
if(!!opener && window.name === "osBrokerSignUp") {
window.close();
Function setSelectedAccount
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
setSelectedAccount : function (accountId, resolve, reject){
if(tradable.accountMap[accountId]) {
if(accountId !== tradable.selectedAccountId)
tradable.log("Setting account: " + ((accountId && accountId.length) ? (accountId.substring(0, accountId.length/2)) : accountId) + "..");
tradable.lastSnapshot = undefined;
Function placeProtectedOrderForAccount
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
placeProtectedOrderForAccount : function (accountId, amount, price, side, instrumentId, type, takeProfitPrice, stopLossPrice, currentBidOrAskPrice, resolve, reject) {
Function isGreaterOrEqualMinVersion
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
function isGreaterOrEqualMinVersion(a, b) {
this.toNum = function(n) {
return parseInt(n, 10);
};
- 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 placeProtectedOrder
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
placeProtectedOrder : function (amount, price, side, instrumentId, type, takeProfitPrice, stopLossPrice, currentBidOrAskPrice, resolve, reject) {
Function getInstrumentsFromIdsForAccount
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
getInstrumentsFromIdsForAccount : function (accountId, instrumentIds, resolve, reject){
var deferred = new $.Deferred();
var missingIds = [];
if(!isFullInstrumentListAvailableForAccount(accountId)) {
Function processAccountUpdate
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function processAccountUpdate() {
if(tradable.tradingEnabled && !tradable.initializingAccount && !processingUpdate &&
(accountUpdatedCallbacks.length > 0 || typeof callbackHolder["accountUpdated"] !== undefined)) {
var processingAccountId = tradable.selectedAccountId;
processingUpdate = true;
Function makeCandleRequest
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
makeCandleRequest : function (method, insIdsArray, resolve, reject, postObject) {
var postObj = {'instrumentIds': insIdsArray};
if(method === "getQuotes") {
postObj = {'symbols': insIdsArray};
}
Function getDefaultInstruments
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function getDefaultInstruments() {
var deferred = new $.Deferred();
if(isFullInstrumentListAvailable()) {
getInstruments().then(function(acctInstruments) {
Function modifyProtectedOrderForAccount
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
modifyProtectedOrderForAccount : function (accountId, order, newPrice, takeProfitPrice, stopLossPrice, currentBidOrAskPrice, resolve, reject) {
Function placeOrderForAccount
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
placeOrderForAccount : function (accountId, amount, price, side, instrumentId, type, resolve, reject){
Function makeOsRequest
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
makeOsRequest : function (reqType, type, accountId, method, postData, resolve, reject){
Function placeStopOrderForAccount
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
placeStopOrderForAccount : function (accountId, amount, price, side, instrumentId, resolve, reject){
Function placeLimitOrderForAccount
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
placeLimitOrderForAccount : function (accountId, amount, price, side, instrumentId, resolve, reject){
Function makeProtectionRequestForAccount
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
makeProtectionRequestForAccount : function (method, accountId, positionId, newPrice, type, resolve, reject) {
Function getCandlesForAccount
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
getCandlesForAccount : function (accountId, instrumentId, from, to, aggregation, resolve, reject) {