WikiEducationFoundation/WikiEduDashboard

View on GitHub
app/assets/javascripts/components/revisions/diff_viewer.jsx

Summary

Maintainability
C
1 day
Test Coverage
C
70%

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

  render() {
    if (!this.shouldShowDiff(this.props) || !this.props.revision) {
      return (
        <div className={`tooltip-trigger ${this.props.showButtonClass}`}>
          <button onClick={this.showDiff} aria-label="Open Diff Viewer" className="icon icon-diff-viewer"/>
Severity: Major
Found in app/assets/javascripts/components/revisions/diff_viewer.jsx - About 3 hrs to fix

    File diff_viewer.jsx has 287 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import React from 'react';
    import createReactClass from 'create-react-class';
    import PropTypes from 'prop-types';
    import SalesforceMediaButtons from '../articles/salesforce_media_buttons.jsx';
    import Loading from '../common/loading.jsx';
    Severity: Minor
    Found in app/assets/javascripts/components/revisions/diff_viewer.jsx - About 2 hrs to fix

      DiffViewer has 24 functions (exceeds 20 allowed). Consider refactoring.
      Open

      const DiffViewer = createReactClass({
        displayName: 'DiffViewer',
      
        // Diff viewer takes a main (final) revision, and optionally a first revision.
        // If a first revision is supplied, it fetches a diff from the parent of the
      Severity: Minor
      Found in app/assets/javascripts/components/revisions/diff_viewer.jsx - About 2 hrs to fix

        Function fetchDiff has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          fetchDiff(diffUrl) {
            fetch(diffUrl)
            .then(resp => resp.json())
            .then((data) => {
              let firstRevisionData;
        Severity: Minor
        Found in app/assets/javascripts/components/revisions/diff_viewer.jsx - About 1 hr to fix

          Function render has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            render() {
              if (!this.shouldShowDiff(this.props) || !this.props.revision) {
                return (
                  <div className={`tooltip-trigger ${this.props.showButtonClass}`}>
                    <button onClick={this.showDiff} aria-label="Open Diff Viewer" className="icon icon-diff-viewer"/>
          Severity: Minor
          Found in app/assets/javascripts/components/revisions/diff_viewer.jsx - About 55 mins 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

          There are no issues that match your filters.

          Category
          Status