hummingbird-me/kitsu-web

View on GitHub

Showing 872 of 872 total issues

File create-post.js has 276 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Component from '@ember/component';
import { inject as service } from '@ember/service';
import { get, set, setProperties, getProperties, computed } from '@ember/object';
import { isEmpty, isPresent } from '@ember/utils';
import { empty, notEmpty, and, or, equal } from '@ember/object/computed';
Severity: Minor
Found in app/components/stream-feed/create-post.js - About 2 hrs to fix

    Function link has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

      link: computed('activity', function() {
        const activity = get(this, 'activity');
        const streamId = get(this, 'group.streamId');
        const queryParams = { isQueryParams: true, values: { notification: streamId } };
        const [modelType, modelId] = get(activity, 'foreignId').split(':');
    Severity: Minor
    Found in app/components/application/user-notifications/item.js - About 2 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 link has 63 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      link: computed('activity', function() {
        const activity = get(this, 'activity');
        const streamId = get(this, 'group.streamId');
        const queryParams = { isQueryParams: true, values: { notification: streamId } };
        const [modelType, modelId] = get(activity, 'foreignId').split(':');
    Severity: Major
    Found in app/components/application/user-notifications/item.js - About 2 hrs to fix

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

        previewEmbedTask: task(function* () {
          const url = this.get('embedUrl');
          if (!url) { return; }
          return yield this.get('ajax').request('/embeds', {
            method: 'POST',
      Severity: Major
      Found in app/components/stream-feed/items/post/comment-box.js and 1 other location - About 2 hrs to fix
      app/components/stream-feed/create-post.js on lines 196..203

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

      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

        previewEmbedTask: task(function* () {
          const url = this.get('embedUrl');
          if (!url) { return; }
          return yield this.get('ajax').request('/embeds', {
            method: 'POST',
      Severity: Major
      Found in app/components/stream-feed/create-post.js and 1 other location - About 2 hrs to fix
      app/components/stream-feed/items/post/comment-box.js on lines 65..72

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

      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

        Object.keys(invalid).forEach(property => {
          invalid[property].forEach(value => {
            run(context, 'set', property, value);
            assert.ok(context.get(`validations.attrs.${property}.isInvalid`));
          });
      Severity: Major
      Found in tests/helpers/test-validations.js and 1 other location - About 2 hrs to fix
      tests/helpers/test-validations.js on lines 4..9

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

      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

        Object.keys(valid).forEach(property => {
          valid[property].forEach(value => {
            run(context, 'set', property, value);
            assert.ok(context.get(`validations.attrs.${property}.isValid`));
          });
      Severity: Major
      Found in tests/helpers/test-validations.js and 1 other location - About 2 hrs to fix
      tests/helpers/test-validations.js on lines 11..16

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

      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 setHeadTags has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        setHeadTags(model) {
          const data = [{
            type: 'meta',
            tagId: 'meta-description',
            attrs: {
      Severity: Major
      Found in app/routes/media/show.js - About 2 hrs to fix

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

          setupController(controller) {
            this._super(...arguments);
            const parentRoute = get(this, 'routeName').split('.').slice(0, 2).join('.');
            const parentController = this.controllerFor(parentRoute);
            set(controller, 'parent', parentController);
        Severity: Major
        Found in app/routes/media/show/units/index.js and 1 other location - About 2 hrs to fix
        app/routes/media/show/index.js on lines 7..12

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

        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

          setupController(controller) {
            this._super(...arguments);
            const parentRoute = get(this, 'routeName').split('.').slice(0, 2).join('.');
            const parentController = this.controllerFor(parentRoute);
            set(controller, 'parent', parentController);
        Severity: Major
        Found in app/routes/media/show/index.js and 1 other location - About 2 hrs to fix
        app/routes/media/show/units/index.js on lines 32..37

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

        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 setHeadTags has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          setHeadTags(model) {
            const description = get(model, 'content').substring(0, 140);
            return [{
              type: 'meta',
              tagId: 'meta-description',
        Severity: Major
        Found in app/routes/reviews.js - About 2 hrs to fix

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

              return yield new RSVP.Promise((resolve, reject) => {
                RSVP.allSettled(saving).then(data => {
                  const failed = data.filterBy('state', 'rejected');
                  return failed.length > 0 ? reject(failed) : resolve();
                });
          Severity: Major
          Found in app/components/users/edit-profile.js and 1 other location - About 2 hrs to fix
          app/controllers/groups/group/dashboard/settings.js on lines 53..58

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

          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

              return yield new RSVP.Promise((resolve, reject) => {
                RSVP.allSettled(saving).then(data => {
                  const failed = data.filterBy('state', 'rejected');
                  return failed.length > 0 ? reject(failed) : resolve();
                });
          Severity: Major
          Found in app/controllers/groups/group/dashboard/settings.js and 1 other location - About 2 hrs to fix
          app/components/users/edit-profile.js on lines 17..22

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

          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

            getChatMessagesTask: task(function* () {
              return yield this.queryPaginated('leader-chat-message', {
                filter: { group_id: get(this, 'group.id') },
                include: 'user',
                sort: '-created_at'
          Severity: Major
          Found in app/components/groups/dashboard/leaders/leader-chat.js and 1 other location - About 2 hrs to fix
          app/components/groups/tickets/ticket-conversation.js on lines 33..39

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

          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

            canEditPost: computed('model', 'membership', 'post', function() {
              // If you're the owner of the content, or a site-admin then the post is editable
              const canEditPost = get(this, 'postAbility.canEdit');
              if (canEditPost) { return true; }
          
          
          Severity: Major
          Found in app/abilities/group.js and 1 other location - About 2 hrs to fix
          app/abilities/group.js on lines 48..56

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

          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

            canEditComment: computed('model', 'membership', 'comment', function() {
              // If you're the owner of the comment, or a site admin then you can edit
              const canEditComment = get(this, 'commentAbility.canEdit');
              if (canEditComment) { return true; }
          
          
          Severity: Major
          Found in app/abilities/group.js and 1 other location - About 2 hrs to fix
          app/abilities/group.js on lines 38..46

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

          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

            getMessagesTask: task(function* () {
              return yield this.queryPaginated('group-ticket-message', {
                filter: { ticket: get(this, 'ticket.id') },
                include: 'user',
                sort: '-created_at'
          Severity: Major
          Found in app/components/groups/tickets/ticket-conversation.js and 1 other location - About 2 hrs to fix
          app/components/groups/dashboard/leaders/leader-chat.js on lines 33..39

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

          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 primaryUnit has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

            primaryUnit: computed('stat.time', function () {
              if (get(this, 'kind') === 'anime') {
                const time = moment.duration(get(this, 'stat.time'), 'seconds');
                for (let i = 0; i < UNITS.length; i += 1) {
                  const unitTime = time.as(UNITS[i]);
          Severity: Minor
          Found in app/components/stats/time-spent.js - About 2 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 headTags has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            headTags() {
              const title = get(this, 'head.title');
              const description = 'Share anime and manga experiences, get recommendations and see what friends are watching or reading.';
              return [{
                type: 'title',
          Severity: Major
          Found in app/routes/application.js - About 2 hrs to fix

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

              _getRatingGroup(rating) {
                if (rating > 0 && rating < 4) {
                  return 'awful';
                }
            
            
            Severity: Major
            Found in app/models/library-entry.js and 1 other location - About 2 hrs to fix
            app/components/library-entry/readonly-rating.js on lines 18..32

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

            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

            Severity
            Category
            Status
            Source
            Language