tradable/tradable-core

View on GitHub

Showing 49 of 55 total issues

File tradable.js has 1939 lines of code (exceeds 250 allowed). Consider refactoring.
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() {} };
}
Severity: Major
Found in src/tradable.js - About 5 days to fix

    Function makeOsRequest has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    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;
    Severity: Major
    Found in src/tradable.js - About 2 hrs to fix

      Function searchInstrumentsForAccount has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              searchInstrumentsForAccount : function (accountId, query, resolve, reject){
                  var deferred = new $.Deferred();
      
                  if(isFullInstrumentListAvailableForAccount(accountId)) {
                      var instrumentsDeferred = new $.Deferred();
      Severity: Major
      Found in src/tradable.js - About 2 hrs to fix

        Function startCandleUpdates has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                startCandleUpdates : function(instrumentId, from, aggregation, callback) {
                    tradable.stopCandleUpdates();
        
                    var aggregationInMillis = aggregation * 60 * 1000;
                    tradable.subscribedCandleId = instrumentId;
        Severity: Major
        Found in src/tradable.js - About 2 hrs to fix

          Function initializeLibrary has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function initializeLibrary(){
                  var success = false;
                  var opener = window.opener;
                  if(!!opener && window.name === "osBrokerSignUp") {
                      window.close();
          Severity: Minor
          Found in src/tradable.js - About 1 hr to fix

            Function setSelectedAccount has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            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;
            Severity: Minor
            Found in src/tradable.js - About 1 hr to fix

              Function placeProtectedOrderForAccount has 11 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      placeProtectedOrderForAccount : function (accountId, amount, price, side, instrumentId, type, takeProfitPrice, stopLossPrice, currentBidOrAskPrice, resolve, reject) {
              Severity: Major
              Found in src/tradable.js - About 1 hr to fix

                Function isGreaterOrEqualMinVersion has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                function isGreaterOrEqualMinVersion(a, b) {
                    this.toNum = function(n) {
                        return parseInt(n, 10);
                    };
                
                Severity: Minor
                Found in src/tradable.js - About 1 hr to fix

                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

                        placeProtectedOrder : function (amount, price, side, instrumentId, type, takeProfitPrice, stopLossPrice, currentBidOrAskPrice, resolve, reject) {
                Severity: Major
                Found in src/tradable.js - About 1 hr to fix

                  Function getInstrumentsFromIdsForAccount has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          getInstrumentsFromIdsForAccount : function (accountId, instrumentIds, resolve, reject){
                              var deferred = new $.Deferred();
                  
                              var missingIds = [];
                              if(!isFullInstrumentListAvailableForAccount(accountId)) {
                  Severity: Minor
                  Found in src/tradable.js - About 1 hr to fix

                    Function processAccountUpdate has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        function processAccountUpdate() {
                            if(tradable.tradingEnabled && !tradable.initializingAccount && !processingUpdate &&
                                (accountUpdatedCallbacks.length > 0 || typeof callbackHolder["accountUpdated"] !== undefined)) {
                                var processingAccountId = tradable.selectedAccountId;
                                processingUpdate = true;
                    Severity: Minor
                    Found in src/tradable.js - About 1 hr to fix

                      Function makeCandleRequest has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              makeCandleRequest : function (method, insIdsArray, resolve, reject, postObject) {
                                  var postObj = {'instrumentIds': insIdsArray};
                                  if(method === "getQuotes") {
                                      postObj = {'symbols': insIdsArray};
                                  }
                      Severity: Minor
                      Found in src/tradable.js - About 1 hr to fix

                        Function getDefaultInstruments has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            function getDefaultInstruments() {
                                var deferred = new $.Deferred();
                        
                                if(isFullInstrumentListAvailable()) {
                                    getInstruments().then(function(acctInstruments) {
                        Severity: Minor
                        Found in src/tradable.js - About 1 hr to fix

                          Function modifyProtectedOrderForAccount has 8 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                                  modifyProtectedOrderForAccount : function (accountId, order, newPrice, takeProfitPrice, stopLossPrice, currentBidOrAskPrice, resolve, reject) {
                          Severity: Major
                          Found in src/tradable.js - About 1 hr to fix

                            Function placeOrderForAccount has 8 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                    placeOrderForAccount : function (accountId, amount, price, side, instrumentId, type, resolve, reject){
                            Severity: Major
                            Found in src/tradable.js - About 1 hr to fix

                              Function makeOsRequest has 7 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                      makeOsRequest : function (reqType, type, accountId, method, postData, resolve, reject){
                              Severity: Major
                              Found in src/tradable.js - About 50 mins to fix

                                Function placeStopOrderForAccount has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                        placeStopOrderForAccount : function (accountId, amount, price, side, instrumentId, resolve, reject){
                                Severity: Major
                                Found in src/tradable.js - About 50 mins to fix

                                  Function placeLimitOrderForAccount has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                          placeLimitOrderForAccount : function (accountId, amount, price, side, instrumentId, resolve, reject){
                                  Severity: Major
                                  Found in src/tradable.js - About 50 mins to fix

                                    Function makeProtectionRequestForAccount has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                    Open

                                            makeProtectionRequestForAccount : function (method, accountId, positionId, newPrice, type, resolve, reject) {
                                    Severity: Major
                                    Found in src/tradable.js - About 50 mins to fix

                                      Function getCandlesForAccount has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                      Open

                                              getCandlesForAccount : function (accountId, instrumentId, from, to, aggregation, resolve, reject) {
                                      Severity: Major
                                      Found in src/tradable.js - About 50 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language