thepracticaldev/dev.to

View on GitHub

Showing 420 of 420 total issues

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

  handleKeyDown = e => {
    const component = this;

    if (component.selected.length === MAX_TAGS && e.keyCode === KEYS.COMMA) {
      e.preventDefault();
Severity: Major
Found in app/javascript/listings/elements/tags.jsx and 1 other location - About 3 days to fix
app/javascript/article-form/elements/tags.jsx on lines 191..239

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

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

  handleKeyDown = e => {
    const component = this;

    if (component.selected.length === MAX_TAGS && e.keyCode === KEYS.COMMA) {
      e.preventDefault();
Severity: Major
Found in app/javascript/article-form/elements/tags.jsx and 1 other location - About 3 days to fix
app/javascript/listings/elements/tags.jsx on lines 216..264

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

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 chat.jsx has 923 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { h, Component } from 'preact';
import PropTypes from 'prop-types';
import ConfigImage from 'images/three-dots.svg';
import {
  conductModeration,
Severity: Major
Found in app/javascript/chat/chat.jsx - About 2 days to fix

    Class User has 82 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class User < ApplicationRecord
      include CloudinaryHelper
    
      attr_accessor(
        :scholar_email, :new_note, :note_for_current_role, :user_status, :pro, :merge_user_id,
    Severity: Major
    Found in app/models/user.rb - About 1 day to fix

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

        handleInput = e => {
          let { value } = e.target;
          // If we start typing immediately after a comma, add a space
          // before what we typed.
          // e.g. If value = "javascript," and we type a "p",
      Severity: Major
      Found in app/javascript/listings/elements/tags.jsx and 1 other location - About 1 day to fix
      app/javascript/article-form/elements/tags.jsx on lines 102..134

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

      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

        handleInput = e => {
          let { value } = e.target;
          // If we start typing immediately after a comma, add a space
          // before what we typed.
          // e.g. If value = "javascript," and we type a "p",
      Severity: Major
      Found in app/javascript/article-form/elements/tags.jsx and 1 other location - About 1 day to fix
      app/javascript/listings/elements/tags.jsx on lines 118..150

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

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

      function initializePodcastPlayback() {
        function getById(name) {
          return document.getElementById(name);
        }
      
      
      Severity: Major
      Found in app/assets/javascripts/initializers/initializePodcastPlayback.js - About 1 day to fix

        Function render has 234 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          render() {
            const {
              listings,
              query,
              tags,
        Severity: Major
        Found in app/javascript/listings/listings.jsx - About 1 day to fix

          Function render has 226 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            render() {
              const { user} = this.props;
              const channelId = this.props.activeChannelId;
              const channel = this.props.activeChannel || {};
              const socialIcons = [];
          Severity: Major
          Found in app/javascript/chat/userDetails.jsx - About 1 day to fix

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

              insertTag(tag) {
                const input = document.getElementById('tag-input');
            
                const range = this.getRangeBetweenCommas(input.value, input.selectionStart);
                const insertingAtEnd = range[1] === input.value.length;
            Severity: Major
            Found in app/javascript/listings/elements/tags.jsx and 1 other location - About 1 day to fix
            app/javascript/article-form/elements/tags.jsx on lines 271..290

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

            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

              insertTag(tag) {
                const input = document.getElementById('tag-input');
            
                const range = this.getRangeBetweenCommas(input.value, input.selectionStart);
                const insertingAtEnd = range[1] === input.value.length;
            Severity: Major
            Found in app/javascript/article-form/elements/tags.jsx and 1 other location - About 1 day to fix
            app/javascript/listings/elements/tags.jsx on lines 296..315

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

            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 user.rb has 525 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            class User < ApplicationRecord
              include CloudinaryHelper
            
              attr_accessor(
                :scholar_email, :new_note, :note_for_current_role, :user_status, :pro, :merge_user_id,
            Severity: Major
            Found in app/models/user.rb - About 1 day to fix

              File article.rb has 520 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              class Article < ApplicationRecord
                include CloudinaryHelper
                include ActionView::Helpers
                include AlgoliaSearch
                include Storext.model
              Severity: Major
              Found in app/models/article.rb - About 1 day to fix

                File listings.jsx has 500 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import { h, Component } from 'preact';
                import { SingleListing } from './singleListing';
                
                export class Listings extends Component {
                  state = {
                Severity: Minor
                Found in app/javascript/listings/listings.jsx - About 1 day to fix

                  Class Article has 56 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  class Article < ApplicationRecord
                    include CloudinaryHelper
                    include ActionView::Helpers
                    include AlgoliaSearch
                    include Storext.model
                  Severity: Major
                  Found in app/models/article.rb - About 1 day to fix

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

                    const orgOptions = (organizations, organizationId) => {
                      const orgs = organizations.map((organization) => {
                        if(organizationId === organization.id) {
                          return(
                            <option value={organization.id} selected>{organization.name}</option>
                    Severity: Major
                    Found in app/javascript/article-form/elements/orgSettings.jsx and 1 other location - About 7 hrs to fix
                    app/javascript/listings/elements/orgSettings.jsx on lines 5..19

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

                    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

                    const orgOptions = (organizations, organizationId) => {
                      const orgs = organizations.map((organization) => {
                        if (organizationId === organization.id) {
                          return (
                            <option value={organization.id} selected>{organization.name}</option>
                    Severity: Major
                    Found in app/javascript/listings/elements/orgSettings.jsx and 1 other location - About 7 hrs to fix
                    app/javascript/article-form/elements/orgSettings.jsx on lines 4..18

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

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

                      render() {
                        // cover image url should asking for url OR providing option to upload an image
                        const {
                          title,
                          tagList,
                    Severity: Major
                    Found in app/javascript/article-form/articleForm.jsx - About 7 hrs to fix

                      File Onboarding.jsx has 445 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import { h, render, Component } from 'preact';
                      import OnboardingWelcome from './components/OnboardingWelcome';
                      import OnboardingFollowTags from './components/OnboardingFollowTags';
                      import OnboardingFollowUsers from './components/OnboardingFollowUsers';
                      import OnboardingWelcomeThread from './components/OnboardingWelcomeThread';
                      Severity: Minor
                      Found in app/javascript/src/Onboarding.jsx - About 6 hrs to fix

                        Chat has 47 functions (exceeds 20 allowed). Consider refactoring.
                        Open

                        export default class Chat extends Component {
                          static propTypes = {
                            pusherKey: PropTypes.number.isRequired,
                            chatChannels: PropTypes.array.isRequired,
                            chatOptions: PropTypes.object.isRequired,
                        Severity: Minor
                        Found in app/javascript/chat/chat.jsx - About 6 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language