Showing 20 of 30 total issues
Function default
has 125 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default async function (args) {
const argv = minimist(args, {
string: [
'material',
'sources',
Function lemmatize
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
async function lemmatize(sentence) {
const result = await processWithCoreNLP(sentence);
const coreNLPToken = result.document.sentences.sentence.tokens.token;
const tokens = Array.isArray(coreNLPToken) ? coreNLPToken : [coreNLPToken];
const lemmatized = tokens.map((token, i) => {
- 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 default
has 86 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default async function (args) {
const argv = minimist(args, {
string: [
'material',
'sources',
File quiz-generator.js
has 260 lines of code (exceeds 250 allowed). Consider refactoring. Open
import debug from 'debug';
import _ from 'lodash';
import RegExpPresets from './constants/regexp-presets';
import wordDivider from './constants/word-divider';
import Source from './source';
Function lemmatize
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function lemmatize(sentence) {
const result = await processWithCoreNLP(sentence);
const coreNLPToken = result.document.sentences.sentence.tokens.token;
const tokens = Array.isArray(coreNLPToken) ? coreNLPToken : [coreNLPToken];
const lemmatized = tokens.map((token, i) => {
Function default
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default async function (args) {
const argv = minimist(args, {
string: [
'src',
'lang',
Function lemmatized
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
const lemmatized = tokens.map((token, i) => {
let shouldSpaced = true;
let lemma;
switch (token.POS) {
Function parseQuestionSentence
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
parseQuestionSentence({ sentence, wordIndexes }) {
// Here we assume word divider is space.
// If you are dealing with a language it is not the case (e.g. Japanese),
// firstly you have to convert a text using a preprocessor.
const tokenRegExp = new RegExp(`(${this._wordRegExp.source})(\\s*)`, 'g');
Function default
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
export default async function (args) {
const argv = minimist(args, {
string: [
'material',
'sources',
- 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 showUsage
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
const showUsage = () => {
console.log(
`word-quiz-generator coverage --help
word-quiz-generator coverage --material=<path> --sources=<paths> [--lang]
[--show-details] [--show-lemma]
Function showUsage
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
const showUsage = () => {
console.log(
`word-quiz-generator generate --help
word-quiz-generator generate --material=<path> --sources=<paths> --sections --size
[--instruction] [--lang] [--sentenceSeparator=<RegExp>]
Function default
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default async function (text) {
// ---- Remove annotations
const textWithoutAnnotations = removeAnnotations(text);
const emended = textWithoutAnnotations
Function removeAnnotations
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function removeAnnotations(text) {
/**
* Remove a string between `left` and `right` using recursive RegExp.
* @param {string} str a target string
* @param {string} left left delimiter
Function findWordIndexesWithinLemmatizedSentence
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
findWordIndexesWithinLemmatizedSentence({ lemmatizedSentence, phrase }) {
const sentence = lemmatizedSentence;
const phraseRegExp = this.getPhraseRegExp(phrase);
const wordIndexes = [];
Function findSentenceIncludingPhrase
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
async findSentenceIncludingPhrase({ src, phrase }) {
const text = await src.lemmatized.getText();
const phraseRegExp = this.getPhraseRegExp(phrase);
const matches = [];
Function default
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export default async function (text) {
// ---- Remove annotations
const textWithoutAnnotations = removeAnnotations(text);
const emended = textWithoutAnnotations
- 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 quiz
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
async quiz({ sections, size }) {
const [min = 0, max] = sections.split('-').map((num) => Number(num));
const phrasesToTest = _.shuffle(this._phrases.filter((phrase) =>
_.inRange(phrase.section, min, (max || min) + 1),
));
Function parseQuestionSentence
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
parseQuestionSentence({ sentence, wordIndexes }) {
// Here we assume word divider is space.
// If you are dealing with a language it is not the case (e.g. Japanese),
// firstly you have to convert a text using a preprocessor.
const tokenRegExp = new RegExp(`(${this._wordRegExp.source})(\\s*)`, 'g');
- 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 default
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export default async function (text) {
const paragraphs = text.replace(/ /g, '').split(/\n/);
const lemmatizedParagraphs = paragraphs.map((paragraph) => (async () => {
const sentences = paragraph.split('。');
- 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 fetchFileList
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export const fetchFileList = (paths, pattern = /(?:)/) =>
Promise.all(
paths.split(',').map((p) => (async () => {
const ap = path.resolve(p);
const stat = await fs.statAsync(ap);
- 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"