thepracticaldev/dev.to

View on GitHub

Showing 156 of 156 total issues

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

const ImageIcon = () => (
  <svg
    width="24"
    height="24"
    viewBox="0 0 24 24"
Severity: Major
Found in app/javascript/article-form/components/ImageUploader.jsx and 5 other locations - About 2 hrs to fix
app/javascript/chat/ChatChannelSettings/MembershipManager/InvitationLinkManager.jsx on lines 13..26
app/javascript/article-form/components/ClipboardButton.jsx on lines 9..22
app/javascript/article-form/components/Close.jsx on lines 5..18
app/javascript/article-form/components/EditorActions.jsx on lines 6..19
app/javascript/crayons/Modal/Modal.jsx on lines 20..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 87.

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 88 lines of code (exceeds 50 allowed). Consider refactoring.
Open

  render() {
    let searchResultsHTML = '';
    const { searchResults, selectedIndex, showingRulesForTag } = this.state;
    const {
      classPrefix,
Severity: Major
Found in app/javascript/shared/components/tags.jsx - About 2 hrs to fix

    Function render has 88 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

      render() {
        const {
          items,
          itemsLoaded,
          totalCount,
    Severity: Major
    Found in app/javascript/readingList/readingList.jsx - About 2 hrs to fix

      ArticleForm has 23 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export default class ArticleForm extends Component {
        static handleGistPreview() {
          const els = document.getElementsByClassName('ltag_gist-liquid-tag');
          for (let i = 0; i < els.length; i += 1) {
            postscribe(els[i], els[i].firstElementChild.outerHTML);
      Severity: Minor
      Found in app/javascript/article-form/articleForm.jsx - About 2 hrs to fix

        File articles_controller.rb has 265 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        class ArticlesController < ApplicationController
          include ApplicationHelper
        
          before_action :authenticate_user!, except: %i[feed new]
          before_action :set_article, only: %i[edit manage update destroy stats]
        Severity: Minor
        Found in app/controllers/articles_controller.rb - About 2 hrs to fix

          Tags has 22 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Tags extends Component {
            constructor(props) {
              super(props);
              const { listing } = props;
          
          
          Severity: Minor
          Found in app/javascript/shared/components/tags.jsx - About 2 hrs to fix

            Function render has 83 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

              render() {
                const { prev, currentSlideIndex, slidesCount } = this.props;
                const { selectedTags, allTags } = this.state;
                const canSkip = selectedTags.length === 0;
            
            
            Severity: Major
            Found in app/javascript/onboarding/components/FollowTags.jsx - About 2 hrs to fix

              Function loadFunctionality has 82 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              function loadFunctionality() {
                if (!document.getElementById('notification-subscriptions-area')) {
                  return;
                }
                const { notifiableId } = document.getElementById(
              Severity: Major
              Found in app/javascript/packs/notificationSubscriptionHandler.js - About 2 hrs to fix

                File responseTemplates.js has 259 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                /* eslint-disable no-alert */
                /* eslint-disable no-restricted-globals */
                
                function toggleTemplateTypeButton(form, e) {
                  const { targetType } = e.target.dataset;
                Severity: Minor
                Found in app/javascript/responseTemplates/responseTemplates.js - About 2 hrs to fix

                  File constants.rb has 259 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  module Constants
                    ALLOWED_MASTODON_INSTANCES = [
                      "101010.pl",
                      "4estate.media",
                      "acg.mn",
                  Severity: Minor
                  Found in app/lib/constants.rb - About 2 hrs to fix

                    Function render has 80 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                      render() {
                        const {
                          id,
                          title,
                          bodyMarkdown,
                    Severity: Major
                    Found in app/javascript/listings/listingForm.jsx - About 2 hrs to fix

                      Class ArticlesController has 21 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      class ArticlesController < ApplicationController
                        include ApplicationHelper
                      
                        before_action :authenticate_user!, except: %i[feed new]
                        before_action :set_article, only: %i[edit manage update destroy stats]
                      Severity: Minor
                      Found in app/controllers/articles_controller.rb - About 2 hrs to fix

                        File markdown_parser.rb has 252 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        class MarkdownParser
                          include ApplicationHelper
                          include CloudinaryHelper
                        
                          BAD_XSS_REGEX = [
                        Severity: Minor
                        Found in app/labor/markdown_parser.rb - About 2 hrs to fix

                          File chat_channel_memberships_controller.rb has 251 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          class ChatChannelMembershipsController < ApplicationController
                            before_action :authenticate_user!
                            after_action :verify_authorized, except: %w[join_channel request_details]
                          
                            include MessagesHelper
                          Severity: Minor
                          Found in app/controllers/chat_channel_memberships_controller.rb - About 2 hrs to fix

                            Function render has 75 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                              render() {
                                const {
                                  title,
                                  tagList,
                                  bodyMarkdown,
                            Severity: Major
                            Found in app/javascript/article-form/articleForm.jsx - About 2 hrs to fix

                              Function render has 70 lines of code (exceeds 50 allowed). Consider refactoring.
                              Open

                                render() {
                                  const { users, selectedUsers } = this.state;
                                  const { prev, slidesCount, currentSlideIndex } = this.props;
                                  const canSkip = selectedUsers.length === 0;
                              
                              
                              Severity: Major
                              Found in app/javascript/onboarding/components/FollowUsers.jsx - About 1 hr to fix

                                Function render has 68 lines of code (exceeds 50 allowed). Consider refactoring.
                                Open

                                  render() {
                                    const {
                                      onSaveDraft,
                                      onPublish,
                                      onClearChanges,
                                Severity: Major
                                Found in app/javascript/article-form/components/EditorActions.jsx - About 1 hr to fix

                                  Function render has 66 lines of code (exceeds 50 allowed). Consider refactoring.
                                  Open

                                    render() {
                                      const {
                                        id,
                                        title,
                                        publishedAt,
                                  Severity: Major
                                  Found in app/javascript/modCenter/singleArticle/index.jsx - About 1 hr to fix

                                    Function sendFetch has 65 lines of code (exceeds 50 allowed). Consider refactoring.
                                    Open

                                    function sendFetch(switchStatement, body) {
                                      switch (switchStatement) {
                                        case 'article-preview':
                                          return fetchCallback({
                                            url: '/articles/preview',
                                    Severity: Major
                                    Found in app/assets/javascripts/utilities/sendFetch.js - About 1 hr to fix

                                      Function insertArticles has 63 lines of code (exceeds 50 allowed). Consider refactoring.
                                      Open

                                      function insertArticles(articles) {
                                        var list = document.getElementById('substories');
                                        var newArticlesHTML = '';
                                        var el = document.getElementById('home-articles-object');
                                        if (el) {
                                      Severity: Major
                                      Found in app/assets/javascripts/initializers/initScrolling.js - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language