app/assets/javascripts/components/revisions/diff_viewer.jsx
Function render
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
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"/>
File diff_viewer.jsx
has 287 lines of code (exceeds 250 allowed). Consider refactoring. Open
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';
DiffViewer
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
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
Function fetchDiff
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
fetchDiff(diffUrl) {
fetch(diffUrl)
.then(resp => resp.json())
.then((data) => {
let firstRevisionData;
Function render
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
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"/>
- Read upRead up
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"