nodaguti/word-quiz-generator

View on GitHub

Showing 30 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',
Severity: Major
Found in src/commands/coverage.js - About 5 hrs to fix

    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) => {
    Severity: Minor
    Found in src/lemmatizers/en.js - About 3 hrs 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 default has 86 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default async function (args) {
      const argv = minimist(args, {
        string: [
          'material',
          'sources',
    Severity: Major
    Found in src/commands/generate.js - About 3 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      function getLemmatizer(argv) {
        try {
          if (argv.lemmatizer) {
            const lemmatizer = require(argv.lemmatizer);
            return lemmatizer.default || lemmatizer;
      Severity: Major
      Found in src/commands/make.js and 1 other location - About 3 hrs to fix
      src/commands/make.js on lines 31..44

      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 102.

      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

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      function getPreprocessor(argv) {
        try {
          if (argv.preprocessor) {
            const preprocessor = require(argv.preprocessor);
            return preprocessor.default || preprocessor;
      Severity: Major
      Found in src/commands/make.js and 1 other location - About 3 hrs to fix
      src/commands/make.js on lines 46..59

      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 102.

      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

      Further Reading

      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';
      Severity: Minor
      Found in src/quiz-generator.js - About 2 hrs to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          get lemmatized() {
            if (this._lemmatized) {
              return this._lemmatized;
            }
        
        
        Severity: Major
        Found in src/source.js and 1 other location - About 2 hrs to fix
        src/source.js on lines 19..29

        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 75.

        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

        Further Reading

        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) => {
        Severity: Minor
        Found in src/lemmatizers/en.js - About 2 hrs to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            get preprocessed() {
              if (this._preprocessed) {
                return this._preprocessed;
              }
          
          
          Severity: Major
          Found in src/source.js and 1 other location - About 2 hrs to fix
          src/source.js on lines 31..41

          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 75.

          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

          Further Reading

          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',
          Severity: Minor
          Found in src/commands/make.js - About 1 hr to fix

            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) {
            Severity: Minor
            Found in src/lemmatizers/en.js - About 1 hr to fix

              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');
              Severity: Minor
              Found in src/quiz-generator.js - About 1 hr to fix

                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',
                Severity: Minor
                Found in src/commands/coverage.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

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                function processWithCoreNLP(text) {
                  return new Promise((resolve, reject) => {
                    coreNLP.process(text, (err, result) => {
                      /* istanbul ignore if */
                      if (err) {
                Severity: Major
                Found in src/preprocessors/en.js and 1 other location - About 1 hr to fix
                src/lemmatizers/en.js on lines 23..33

                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 65.

                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

                Further Reading

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                function processWithCoreNLP(text) {
                  return new Promise((resolve, reject) => {
                    coreNLP.process(text, (err, result) => {
                      /* istanbul ignore if */
                      if (err) {
                Severity: Major
                Found in src/lemmatizers/en.js and 1 other location - About 1 hr to fix
                src/preprocessors/en.js on lines 15..25

                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 65.

                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

                Further Reading

                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>]
                Severity: Minor
                Found in src/commands/generate.js - About 1 hr to fix

                  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]
                  Severity: Minor
                  Found in src/commands/coverage.js - About 1 hr to fix

                    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
                    Severity: Minor
                    Found in src/preprocessors/ojp.js - About 1 hr to fix

                      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
                      Severity: Minor
                      Found in src/preprocessors/ojp.js - About 1 hr to fix

                        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 = [];
                        
                        
                        Severity: Minor
                        Found in src/quiz-generator.js - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language