Inlife/nexrender

View on GitHub

Showing 51 of 75 total issues

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

module.exports = (job, settings) => {
    settings.logger.log(`[${job.uid}] setting up job...`);

    try {
        assert(validate(job) == true)
Severity: Minor
Found in packages/nexrender-core/src/tasks/setup.js - About 1 hr to fix

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

    const upload = (job, settings, src, params) => {
        if (!params.host) throw new Error('FTP Host not provided.')
        if (!params.port) throw new Error('FTP Port not provided.')
        if (!params.user) throw new Error('FTP Username not provided.')
        if (!params.password) throw new Error('FTP Password not provided.')
    Severity: Minor
    Found in packages/nexrender-provider-ftp/src/index.js - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

          if (event == 'Job Cleanup') {
              const events = Object.keys(cache.data)
      
              for (let i = 0; i < events.length; i++) {
                  const combinedEvent = events[i]
      Severity: Critical
      Found in packages/nexrender-core/src/helpers/analytics.js - About 1 hr to fix

        Function exports has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = (job, settings, options/*, type */) => {
            settings.logger.log(`[${job.uid}] starting action-encode action (ffmpeg)`)
        
            return new Promise((resolve, reject) => {
                const params = constructParams(job, settings, options);
        Severity: Minor
        Found in packages/nexrender-action-encode/index.js - About 1 hr to fix

          Function validate has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const validate = job => {
              assert(job.uid, 'job must have uid');
              assert(job.state, 'job must have state');
          
              assert(job.template, 'job must have template object defined');
          Severity: Minor
          Found in packages/nexrender-types/job.js - About 1 hr to fix

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

            const withEventEmitter = (wrappedFetch, job, polling = NEXRENDER_JOB_POLLING) => {
                const emitter  = new EventEmitter();
                const interval = setInterval(async () => {
                    try {
                        const updatedJob = await wrappedFetch(`/jobs/${job.uid}/status`)
            Severity: Minor
            Found in packages/nexrender-api/src/job.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 wrappedFetch has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                const wrappedFetch = async (path, options) => {
                    options = options || {}
                    const defaultHeaders = {};
            
                    if (headers) {
            Severity: Minor
            Found in packages/nexrender-api/src/index.js - About 1 hr to fix

              Function exports has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports = async (req, res) => {
                  const release = await mutex.acquire();
              
                  try{
                      console.log(`fetching a pickup job for a worker`)
              Severity: Minor
              Found in packages/nexrender-server/src/routes/jobs-pickup.js - About 1 hr to fix

                Function buildParameterConfigurator has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    EnhancedScript.prototype.buildParameterConfigurator = function () {
                        const defaultGlobalValue = this.getStringifiedDefaultValue( this.defaults.global );
                        // const defaultFnValue = this.getDefaultValue( this.defaults.function );
                        const createParameterConfigurator = () => `
                            function ParameterConfigurator () {
                Severity: Minor
                Found in packages/nexrender-core/src/tasks/script/EnhancedScript.js - About 1 hr to fix

                  Function exports has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  module.exports = (job, settings) => {
                      settings.logger.log(`[${job.uid}] running script assemble...`);
                  
                      const data = [];
                      const base = job.workpath;
                  Severity: Minor
                  Found in packages/nexrender-core/src/tasks/script/index.js - About 1 hr to fix

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

                    const init = (settings) => {
                        settings = Object.assign({}, settings);
                        settings.logger = settings.logger || console;
                        settings.track = (...args) => track(settings, ...args);
                        settings.trackCombined = (event, params) => track(settings, event, { combined: true, ...params });
                    Severity: Minor
                    Found in packages/nexrender-core/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 exports has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    module.exports = (job, settings) => {
                        settings.logger.log(`[${job.uid}] setting up job...`);
                    
                        try {
                            assert(validate(job) == true)
                    Severity: Minor
                    Found in packages/nexrender-core/src/tasks/setup.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 constructParams has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const constructParams = (job, settings, { preset, input, output, params }) => {
                        input = input || job.output;
                    
                        if (!path.isAbsolute(output)) output = path.join(job.workpath, output);
                    
                    
                    Severity: Minor
                    Found in packages/nexrender-action-encode/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 uriDigitalOcean has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function uriDigitalOcean(src) {
                      const parsed = url.parse(src)
                      const result = parsed.host.match(/(([^.]+)\.)?([^.]+)\.digitaloceanspaces\.com/)
                    
                      if (!result) {
                    Severity: Minor
                    Found in packages/nexrender-provider-s3/src/uri.js - About 1 hr to fix

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

                      const upload = (job, settings, src, params) => {
                          if (!params.host) throw new Error("SFTP Host not provided.");
                          if (!params.port) throw new Error("SFTP Port not provided.");
                          if (!params.user) throw new Error("SFTP Username not provided.");
                          if (!params.password) throw new Error("SFTP Password not provided.");
                      Severity: Minor
                      Found in packages/nexrender-provider-sftp/src/index.js - About 1 hr to fix

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

                        const upload = async (job, settings, src, params) => {
                            if (!params.url) throw new Error('Provider NX: URL not provided.')
                        
                            const file = fs.createReadStream(src);
                            const fileSize = fs.statSync(src).size;
                        Severity: Minor
                        Found in packages/nexrender-provider-nx/src/index.js - About 1 hr to fix

                          Function upload has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                          Open

                          const upload = (job, settings, src, params, onProgress, onComplete) => {
                              const file = fs.createReadStream(src);
                          
                              if (!params.endpoint && !params.region) {
                                  return Promise.reject(new Error('S3 region or endpoint not provided.'))
                          Severity: Minor
                          Found in packages/nexrender-provider-s3/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 parse has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              const parse = (data) => {
                                  const string = ('' + data).replace(/;/g, ':'); /* sanitize string */
                          
                                  // Only execute startRegex if project start hasnt been found
                                  const matchStart = isNaN(parseInt(projectStart)) ? startRegex.exec(string) : false;
                          Severity: Minor
                          Found in packages/nexrender-core/src/tasks/render.js - About 1 hr to fix

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

                                        dest,
                                        src,
                                        parameters = [],
                                        keyword = "NX",
                                        defaults = {
                            Severity: Major
                            Found in packages/nexrender-core/src/tasks/script/EnhancedScript.js - About 50 mins to fix

                              Function exports has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                              Open

                              module.exports = async (req, res) => {
                                  const release = await mutex.acquire();
                              
                                  try{
                                      console.log(`fetching a pickup job for a worker`)
                              Severity: Minor
                              Found in packages/nexrender-server/src/routes/jobs-pickup.js - About 45 mins 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

                              Severity
                              Category
                              Status
                              Source
                              Language