Showing 75 of 75 total issues
Function exports
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = (settings) => {
const targetScript = 'commandLineRenderer.jsx';
const patched = getContentForPatch(settings.binary)
const afterEffects = path.dirname(settings.binary)
Function exports
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
module.exports = (job, settings, { input, provider, params, ...options }, type) => {
let onProgress;
let onComplete;
if (type != 'postrender') {
- 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 upload
has 60 lines of code (exceeds 25 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.'))
File render.js
has 256 lines of code (exceeds 250 allowed). Consider refactoring. Open
const fs = require('fs')
const path = require('path')
const {spawn} = require('child_process')
const {expandEnvironmentVariables, checkForWSL} = require('../helpers/path')
Function upload
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
const upload = (job, settings, src, params) => {
if (!params.bucket) {
return Promise.reject(new Error('GCS bucket not provided.'))
}
if (!params.item) {
Function getBinary
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
const getBinary = (job, settings) => {
return new Promise((resolve, reject) => {
const {version} = pkg['ffmpeg-static']
const filename = `ffmpeg-${version}${process.platform == 'win32' ? '.exe' : ''}`
const fileurl = `https://github.com/eugeneware/ffmpeg-static/releases/download/${version}/${process.platform}-x64`
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)
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.')
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]
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (fs.existsSync(logPath)) {
settings.logger.log(`[${job.uid}] dumping aerender log:`)
settings.logger.log(fs.readFileSync(logPath, 'utf8'))
}
- 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 67.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (fs.existsSync(logPath)) {
settings.logger.log(`[${job.uid}] dumping aerender log:`)
settings.logger.log(fs.readFileSync(logPath, 'utf8'))
}
- 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 67.
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 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);
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');
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`)
- 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 wrappedFetch
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
const wrappedFetch = async (path, options) => {
options = options || {}
const defaultHeaders = {};
if (headers) {
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`)
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 () {
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;
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 });
- 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 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)
- 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"