Showing 110 of 220 total issues
Function render
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const {
user,
collections,
runCommand,
Function localSearch
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function localSearch(searchTerm, getState, dispatch) {
return (function acc(localResults = { entries: [] }) {
function processCollection(collection, collectionKey) {
const state = getState();
if (state.entries.hasIn(['pages', collectionKey, 'ids'])) {
Function render
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const { onAddAsset, onRemoveAsset, getAsset } = this.props;
return (
<div className={styles.wrapper}>
Function onKeyDown
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function onKeyDown(e, data, state) {
const createDefaultBlock = () => {
return Block.create({
type: 'paragraph',
nodes: [Text.createFromString('')]
Function entries
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const entries = (state = defaultState, action) => {
switch (action.type) {
case SEARCH_CLEAR:
return defaultState;
Function remarkPaddedLinks
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function remarkPaddedLinks() {
function transform(node) {
/**
Function sortKeys
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
Open
const sortKeys = (sortedKeys = []) => (a, b) => {
const idxA = sortedKeys.indexOf(a);
const idxB = sortedKeys.indexOf(b);
if (idxA === -1 || idxB === -1) {
if (a > b) return 1;
- 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"
Further reading
Function processCollection
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function processCollection(collection, collectionKey) {
const state = getState();
if (state.entries.hasIn(['pages', collectionKey, 'ids'])) {
const searchFields = [
selectInferedField(collection, 'title'),
Function EntryPageHOC
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function EntryPageHOC(EntryPage) {
class EntryPageHOC extends React.Component {
render() {
return <EntryPage {...this.props} />;
}
Function remarkUnwrapInvalidNest
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function remarkUnwrapInvalidNest() {
return transform;
function transform(tree) {
const invalidNest = findInvalidNest(tree);
Function render
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const {
entry,
entryDraft,
fields,
Function authenticate
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
authenticate(options, cb) {
var left, top, url,
siteID = this.getSiteID(),
provider = options.provider;
if (!provider) {
Function upload
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
upload(file, privateUpload = false) {
const fileData = {
name: file.name,
size: file.size
};
Function unpublishedEntries
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
unpublishedEntries() {
return this.api.listUnpublishedBranches().then((branches) => {
const sem = semaphore(MAX_CONCURRENT_DOWNLOADS);
const promises = [];
branches.map((branch) => {
Function render
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const {
plugin,
onSubmit,
onCancel,
Function persistEntry
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
persistEntry(config, collection, entryDraft, MediaFiles, options) {
const newEntry = entryDraft.getIn(["entry", "newRecord"]) || false;
const parsedData = {
title: entryDraft.getIn(["entry", "data", "title"], "No Title"),
Consider simplifying this complex logical expression. Open
Open
if (!unpublished) {
// Open new editorial review workflow for this entry - Create new metadata and commit to new branch`
const contentKey = entry.slug;
const branchName = `cms/${ contentKey }`;
Function updateTree
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
updateTree(sha, path, fileTree) {
return this.getTree(sha)
.then((tree) => {
let obj;
let filename;
Function controlFor
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
controlFor(field) {
const { entry, fieldsMetaData, fieldsErrors, getAsset, onChange, onAddAsset, onRemoveAsset } = this.props;
const widget = resolveWidget(field.get('widget'));
const fieldName = field.get('name');
const value = entry.getIn(['data', fieldName]);
Function renderItem
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
renderItem(item, index) {
const { value, field, getAsset, onAddAsset, onRemoveAsset } = this.props;
const { itemStates } = this.state;
const collapsed = itemStates.getIn([index, 'collapsed']);
const classNames = [styles.item, collapsed ? styles.collapsed : styles.expanded];