thepracticaldev/dev.to

View on GitHub

Showing 174 of 364 total issues

File chat.jsx has 904 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

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

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

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

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

        Function initializePodcastPlayback has 213 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

          File user.rb has 494 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          class User < ApplicationRecord
            include CloudinaryHelper
          
            attr_accessor :scholar_email, :new_note, :quick_match, :mentorship_note, :note_for_current_role, :add_mentor, :add_mentee, :user_status, :toggle_mentorship, :pro, :merge_user_id
          
          
          Severity: Minor
          Found in app/models/user.rb - About 7 hrs to fix

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

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

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

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

                Function drawCharts has 170 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function drawCharts(data, timeRange) {
                  const labels = Object.keys(data);
                  const parsedData = Object.entries(data).map(date => date[1]);
                  const comments = parsedData.map(date => date.comments.total);
                  const reactions = parsedData.map(date => date.reactions.total);
                Severity: Major
                Found in app/javascript/packs/proCharts.js - About 6 hrs to fix

                  File Onboarding.jsx has 444 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

                    Function initializePodcastPlayback has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function initializePodcastPlayback() {
                    
                      function getById(name) {
                        return document.getElementById(name);
                      }
                    Severity: Minor
                    Found in app/assets/javascripts/initializers/initializePodcastPlayback.js - About 6 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

                    Chat has 44 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

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

                        render() {
                          const channel = this.props.channel; // eslint-disable-line
                          const users = Object.values(channel.channel_users).map(user => (
                            <div className="channeldetails__user">
                              <img
                      Severity: Major
                      Found in app/javascript/chat/channelDetails.jsx - About 5 hrs to fix

                        Function render has 138 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 5 hrs to fix

                          Function Channels has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                          Open

                          const Channels = ({
                            activeChannelId,
                            chatChannels,
                            handleSwitchChannel,
                            expanded,
                          Severity: Minor
                          Found in app/javascript/chat/channels.jsx - About 4 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

                          Class Comment has 37 methods (exceeds 20 allowed). Consider refactoring.
                          Open

                          class Comment < ApplicationRecord
                            has_ancestry
                            include AlgoliaSearch
                            include Reactable
                            belongs_to :commentable, polymorphic: true
                          Severity: Minor
                          Found in app/models/comment.rb - About 4 hrs to fix

                            Function channels has 108 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              const channels = chatChannels.map(channel => {
                                if (!channel) {
                                  return;
                                }
                                const isActive = parseInt(activeChannelId, 10) === channel.id;
                            Severity: Major
                            Found in app/javascript/chat/channels.jsx - About 4 hrs to fix

                              File articleForm.jsx has 344 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              import 'preact/devtools';
                              import { h, Component } from 'preact';
                              import linkState from 'linkstate';
                              import ImageUploadIcon from 'images/image-upload.svg';
                              import ThreeDotsIcon from 'images/three-dots.svg';
                              Severity: Minor
                              Found in app/javascript/article-form/articleForm.jsx - About 4 hrs to fix

                                Function sendFetch has 103 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                function sendFetch(switchStatement, body) {
                                  switch (switchStatement) {
                                    case 'article-preview':
                                      return function(csrfToken) {
                                        return window.fetch('/articles/preview', {
                                Severity: Major
                                Found in app/assets/javascripts/utilities/sendFetch.js - About 4 hrs to fix

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

                                    render() {
                                      const article = this.props.resource;
                                      let heartReactedClass = '';
                                      let unicornReactedClass = '';
                                      let bookmarkReactedClass = '';
                                  Severity: Major
                                  Found in app/javascript/chat/article.jsx - About 3 hrs to fix

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

                                      render() {
                                        const detectIOSSafariClass =
                                          navigator.userAgent.match(/iPhone/i) &&
                                          !navigator.userAgent.match('CriOS')
                                            ? ' chat--iossafari'
                                    Severity: Major
                                    Found in app/javascript/chat/chat.jsx - About 3 hrs to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language