ForestAdmin/forest-express

View on GitHub

Showing 124 of 261 total issues

Function perform has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  this.perform = () => {
    collectionModel = integrationInfo.collection;
    const {
      field: collectionFieldName,
      embeddedPath,
Severity: Minor
Found in src/integrations/stripe/services/payments-getter.js - About 1 hr to fix

    Function collection has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.collection = (name, opts) => {
      if (_.isEmpty(Schemas.schemas) && opts.modelsDir) {
        logger.error(`Cannot customize your collection named "${name}" properly. Did you call the "collection" method in the /forest directory?`);
        return;
      }
    Severity: Minor
    Found in src/index.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 CSVExporter has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    function CSVExporter(params, response, modelName, recordsExporter) {
      const { configStore } = inject();
    
      function getValueForAttribute(record, attribute) {
        let value;
    Severity: Minor
    Found in src/services/csv-exporter.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 createCollections has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.createCollections = (Implementation, apimap, collectionAndFieldName) => {
      const collectionName = collectionAndFieldName.split('.')[0];
      const collectionDisplayName = _.capitalize(collectionName);
    
      // jshint camelcase: false
    Severity: Minor
    Found in src/integrations/close.io/setup.js - About 1 hr to fix

      Function validateOptions has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        validateOptions() {
          const options = this.lianaOptions;
      
          if (!options) {
            throw new Error('Liana options cannot be null.');
      Severity: Minor
      Found in src/services/config-store.js - About 1 hr to fix

        Function perform has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          this.perform = () => {
            collectionModel = integrationInfo.collection;
            const {
              field: collectionFieldName,
              embeddedPath,
        Severity: Minor
        Found in src/integrations/stripe/services/subscriptions-getter.js - About 1 hr to fix

          Function get has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            this.get = async (request, response, next) => {
              let promise = null;
          
              function getAssociationModel(schema, associationName) {
                const field = _.find(schema.fields, { field: associationName });
          Severity: Minor
          Found in src/routes/stats.js - About 1 hr to fix

            Function perform has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              this.perform = () => {
                collectionModel = integrationInfo.collection;
                const {
                  field: collectionFieldName,
                  embeddedPath,
            Severity: Minor
            Found in src/integrations/stripe/services/invoices-getter.js - About 1 hr to fix

              Function IntegrationChecker has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function IntegrationChecker(opts, Implementation) {
                const modules = [
                  new CloseIo(opts, Implementation),
                  new Intercom(opts, Implementation),
                  new Layer(opts, Implementation),
              Severity: Minor
              Found in src/integrations/index.js - About 1 hr to fix

                Function CSVExporter has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function CSVExporter(params, response, modelName, recordsExporter) {
                  const { configStore } = inject();
                
                  function getValueForAttribute(record, attribute) {
                    let value;
                Severity: Minor
                Found in src/services/csv-exporter.js - About 1 hr to fix

                  Function serializeInvoices has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function serializeInvoices(invoices, collectionName, meta) {
                    function getCustomerAttributes() {
                      if (!invoices.length) { return []; }
                  
                      const schema = Schemas.schemas[collectionName];
                  Severity: Minor
                  Found in src/integrations/stripe/serializers/invoices.js - About 1 hr to fix

                    Function MixpanelEventsGetter has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function MixpanelEventsGetter(Implementation, params, options, integrationInfo) {
                      const MixpanelExport = options.integrations.mixpanel.mixpanel;
                      const panel = new MixpanelExport({
                        api_key: options.integrations.mixpanel.apiKey,
                        api_secret: options.integrations.mixpanel.apiSecret,
                    Severity: Minor
                    Found in src/integrations/mixpanel/services/mixpanel-events-getter.js - About 1 hr to fix

                      Function getRoleIdsAllowedToApprove has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        private async getRoleIdsAllowedToApprove(
                          recordsCounterParams: RecordsCounterParams,
                          customActionName: string,
                          collectionName: string,
                          filterForCaller: GenericPlainTree,
                      Severity: Minor
                      Found in src/services/authorization/action-authorization.ts - About 1 hr to fix

                        Function Routes has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        module.exports = function Routes(app, model, Implementation, options) {
                          const { modelsManager } = inject();
                          const modelName = Implementation.getModelName(model);
                          let integrationInfo;
                        
                        
                        Severity: Minor
                        Found in src/integrations/mixpanel/routes.js - About 1 hr to fix

                          Function _ensureRecordIdsInScope has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            _ensureRecordIdsInScope() {
                              return async (request, response, next) => {
                                try {
                                  const { primaryKeys, isVirtual } = Schemas.schemas[this.collectionName];
                          
                          
                          Severity: Minor
                          Found in src/middlewares/permissions.js - About 1 hr to fix

                            Function serializePayments has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function serializePayments(payments, collectionName, meta) {
                              function getCustomerAttributes() {
                                if (!payments.length) { return []; }
                            
                                const schema = Schemas.schemas[collectionName];
                            Severity: Minor
                            Found in src/integrations/stripe/serializers/payments.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 SourceGetter has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function SourceGetter(Implementation, params, opts, integrationInfo) {
                              const stripe = opts.integrations.stripe.stripe(opts.integrations.stripe.apiKey);
                              let collectionModel = null;
                            
                              function getSource(customerId, objectId) {
                            Severity: Minor
                            Found in src/integrations/stripe/services/source-getter.js - About 1 hr to fix

                              Function injectSmartFieldValue has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                function injectSmartFieldValue(field) {
                                  const fieldWasRequested = isRequestedField(requestedField || modelName, field.field);
                              
                                  if (record && field.isVirtual && (field.get || field.value)) {
                                    if (fieldsPerModel && !fieldWasRequested) {
                              Severity: Minor
                              Found in src/services/smart-fields-values-injector.js - About 1 hr to fix

                                Function perform has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                function perform(route, environmentSecret, queryParameters, headers) {
                                  const { forestUrl } = inject();
                                
                                  return new P((resolve, reject) => {
                                    const request = superagent
                                Severity: Minor
                                Found in src/services/forest-server-requester.js - About 1 hr to fix

                                  Function sort has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    sort(apimap) {
                                      try {
                                        apimap = ApimapSorter._reorderKeysBasic(apimap);
                                        apimap.data = ApimapSorter._sortArrayOfObjects(apimap.data);
                                  
                                  
                                  Severity: Minor
                                  Found in src/services/apimap-sorter.js - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language