File episode.ts
has 420 lines of code (exceeds 250 allowed). Consider refactoring. Invalid
'use strict';
import cheerio = require('cheerio');
import fs = require('fs');
import mkdirp = require('mkdirp');
import my_request = require('./my_request');
Function download
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Invalid
function download(config: IConfig, page: IEpisodePage, player: IEpisodePlayer, done: (err: Error | string, ign: boolean) => void)
{
const serieFolder = sanitiseFileName(config.series || page.series);
let fileName = sanitiseFileName(generateName(config, page));
Function scrapePage
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Invalid
function scrapePage(config: IConfig, address: string, done: (err: Error, page?: IEpisodePage) => void)
{
const epId = parseInt((address.match(/[0-9]+$/) || ['0'])[0], 10);
if (!epId)
Function downloadSubtitle
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Wontfix
function downloadSubtitle(config: IConfig, page: IEpisodePage, player: IEpisodePlayer,
filePath: string, done: (err?: Error | string) => void)
{
if (page.media !== null)
{
Function downloadSubtitle
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
function downloadSubtitle(config: IConfig, page: IEpisodePage, player: IEpisodePlayer,
filePath: string, done: (err?: Error | string) => void)
{
if (page.media !== null)
{
- 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 scrapePlayer
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Invalid
function scrapePlayer(config: IConfig, address: string, id: number, done: (err: Error, player?: IEpisodePlayer) => void)
{
const url = address.match(/^(https?:\/\/[^\/]+)/);
if (!url)
Function download
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Invalid
function download(config: IConfig, page: IEpisodePage, player: IEpisodePlayer, done: (err: Error | string, ign: boolean) => void)
{
const serieFolder = sanitiseFileName(config.series || page.series);
let fileName = sanitiseFileName(generateName(config, page));
- 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 downloadVideo
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function downloadVideo(config: IConfig, page: IEpisodePage, player: IEpisodePlayer,
filePath: string, done: (err: any) => void)
{
if (player == null)
{
- 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
Avoid deeply nested control flow statements. Open
if (err)
{
log.error('An error occured while fetching subtitles...');
return done(err);
}
Function downloadVideo
has 5 arguments (exceeds 4 allowed). Consider refactoring. Invalid
function downloadVideo(config: IConfig, page: IEpisodePage, player: IEpisodePlayer,
filePath: string, done: (err: any) => void)
Function downloadSubtitle
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function downloadSubtitle(config: IConfig, page: IEpisodePage, player: IEpisodePlayer,
filePath: string, done: (err?: Error | string) => void)