oglimmer/linky

View on GitHub
server/controller/linkController.js

Summary

Maintainability
D
1 day
Test Coverage

Function process has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async process() {
    try {
      this.validate();
      // update links
      const rawRows = await linkDao.listByUseridAndTag(this.data.userid, this.data.oldTagName);
Severity: Minor
Found in server/controller/linkController.js - About 1 hr to fix

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

    export default {
    
      createLink: (req, res, next) => {
        const crp = new CreateLinkProcessor(req, res, next);
        crp.doProcess();
    Severity: Major
    Found in server/controller/linkController.js and 1 other location - About 7 hrs to fix
    server/controller/userController.js on lines 178..205

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

    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

        if (READONLY_TAGS.findIndex(e => e === this.data.oldTagName) !== -1) {
          throw new Error(`Change to ${this.data.oldTagName} not possible`);
        }
    Severity: Major
    Found in server/controller/linkController.js and 1 other location - About 1 hr to fix
    server/controller/tagController.js on lines 117..119

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

    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 5 locations. Consider refactoring.
    Open

        try {
          this.validate();
          // update links
          const rawRows = await linkDao.listByUseridAndTag(this.data.userid, this.data.oldTagName);
          const docs = rawRows.map((row) => {
    Severity: Major
    Found in server/controller/linkController.js and 4 other locations - About 40 mins to fix
    server/controller/linkController.js on lines 36..47
    server/controller/linkController.js on lines 80..103
    server/controller/tagController.js on lines 75..95
    server/controller/tagController.js on lines 127..148

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

    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 5 locations. Consider refactoring.
    Open

        try {
          const rec = await linkDao.getById(this.data.linkid);
          if (rec.userid !== this.data.userid) {
            throw new Error('Forbidden');
          }
    Severity: Major
    Found in server/controller/linkController.js and 4 other locations - About 40 mins to fix
    server/controller/linkController.js on lines 36..47
    server/controller/linkController.js on lines 136..175
    server/controller/tagController.js on lines 75..95
    server/controller/tagController.js on lines 127..148

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

    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 5 locations. Consider refactoring.
    Open

        try {
          const newLinkRec = await createRecord(this.data, this.data.userid);
          const collateral = await findDuplicatesSingleAddEditLink(this.data.userid, newLinkRec);
          const { id } = await presistRecord(newLinkRec);
          newLinkRec.id = id;
    Severity: Major
    Found in server/controller/linkController.js and 4 other locations - About 40 mins to fix
    server/controller/linkController.js on lines 80..103
    server/controller/linkController.js on lines 136..175
    server/controller/tagController.js on lines 75..95
    server/controller/tagController.js on lines 127..148

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

    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 12 locations. Consider refactoring.
    Open

        try {
          await linkDao.deleteLatest(this.data.linkid, this.data.userid);
          this.res.send({ result: 'ok' });
          // if this was an `archive` delete its archive object and the file cache
          const archiveRec = await archiveDao.getByUserIdAndArchiveLinkId(
    Severity: Major
    Found in server/controller/linkController.js and 11 other locations - About 35 mins to fix
    server/controller/archiveController.js on lines 139..157
    server/controller/imageController.js on lines 23..80
    server/controller/importExportController.js on lines 130..139
    server/controller/importExportController.js on lines 150..157
    server/controller/linkController.js on lines 192..204
    server/controller/rssController.js on lines 183..234
    server/controller/searchController.js on lines 64..106
    server/controller/tagController.js on lines 17..23
    server/controller/userController.js on lines 31..48
    server/controller/userController.js on lines 110..122
    server/controller/userController.js on lines 159..173

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

    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 12 locations. Consider refactoring.
    Open

        try {
          const rows = await linkDao.listByUseridAndTag(this.data.userid, this.data.tags);
          const responseArr = rows.map((row) => {
            const { _id, _rev, ...mappedRow } = row.value;
            mappedRow.id = _id;
    Severity: Major
    Found in server/controller/linkController.js and 11 other locations - About 35 mins to fix
    server/controller/archiveController.js on lines 139..157
    server/controller/imageController.js on lines 23..80
    server/controller/importExportController.js on lines 130..139
    server/controller/importExportController.js on lines 150..157
    server/controller/linkController.js on lines 221..240
    server/controller/rssController.js on lines 183..234
    server/controller/searchController.js on lines 64..106
    server/controller/tagController.js on lines 17..23
    server/controller/userController.js on lines 31..48
    server/controller/userController.js on lines 110..122
    server/controller/userController.js on lines 159..173

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

    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

    There are no issues that match your filters.

    Category
    Status