Showing 29 of 143 total issues
File types.ts
has 1101 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
export type Maybe<T> = T | null;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
File tailwind.js
has 692 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
module.exports = {
prefix: '',
important: false,
separator: ':',
theme: {
Function ChapterShow
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const ChapterShow = () => {
const commit: ChapterAtCommitProps = {
__typename: "Commit",
bookPermalink: "markdown-book-test",
bookTitle: "Markdown Book Test",
Class ElementProcessor
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class ElementProcessor
def initialize(chapter, book_path)
@chapter = chapter
@book_path = book_path
end
Function ElementNote
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const ElementNote: FunctionComponent<ElementNoteProps> = (props) => {
const { user, createdAt, bookPermalink, number, id, text, comments } = props;
const [state, setState] = useState<string>(props.state);
const [showForm, setShowForm] = useState<boolean>(false);
Class ChapterProcessor
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class ChapterProcessor
include Sidekiq::Worker
sidekiq_options retry: 0
Function Root
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const Root: React.FC = () => {
const renderUserInfo = () => {
return (
<CurrentUserContext.Consumer>
{(user: CurrentUserType) =>
Function Comment
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const Comment: FunctionComponent<CommentType> = (props) => {
const { id, user, createdAt } = props;
const [text, setText] = useState<string>(props.text);
const [showForm, setShowForm] = useState<boolean>(false);
const [hidden, setHidden] = useState<boolean>(false);
Function Element
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const Element: React.FC<ElementProps> = (props) => {
const { noteCount: initialNoteCount, id, bookPermalink } = props;
const [noteCount, setNoteCount] = useState<number>(initialNoteCount);
const [showNotes, setShowNotes] = useState<boolean>(false);
Function Form
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const Form: FunctionComponent<FormProps> = (props) => {
const { elementId, bookPermalink, noteSubmitted } = props;
const [text, setText] = useState<string>("");
const [submitNote] = useMutation(submitNoteMutation);
const submit = (e: React.FormEvent<HTMLFormElement>) => {
Function EditForm
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const EditForm: FunctionComponent<EditFormProps> = (props) => {
const { id, originalText, toggleForm } = props;
const [text, setText] = useState<string>(props.originalText);
const [updateComment] = useMutation(updateCommentMutation);
Function EditForm
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const EditForm: FunctionComponent<EditFormProps> = (props) => {
const { noteId, originalText, toggleForm } = props;
const [text, setText] = useState<string>(props.originalText);
const [updateNote] = useMutation(updateNoteMutation);
Function Branch
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const Branch: FunctionComponent<BranchProps> = (props) => {
const [updateBranch] = useUpdateBranchMutation({ errorPolicy: "all" });
const { bookPermalink, bookTitle, name, commits } = props;
const [message, setMessage] = useState<string>("");
Function BooksShow
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const BooksShow = () => {
const commit: Commit = {
__typename: "Commit",
sha: "abc123",
createdAt: "2020-04-15 10:10:10",
Function registerValidSW
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function registerValidSW(swUrl: string, config?: Config) {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
registration.onupdatefound = () => {
Function renderDeleteConfirmation
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const renderDeleteConfirmation = () => {
if (showDeleteConfirmation) {
return (
<div className="text-red-800 mt-4">
<hr />
Method handle
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def handle(req, res)
# TODO!
# raise "states do not match" if session[:state] != params[:state]
res.format = :json
Function ElementNote
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
const ElementNote: FunctionComponent<ElementNoteProps> = (props) => {
const { user, createdAt, bookPermalink, number, id, text, comments } = props;
const [state, setState] = useState<string>(props.state);
const [showForm, setShowForm] = useState<boolean>(false);
- 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
Method run
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def run(query:, variables: {}, context: {})
context = context.merge(
branch_loader: branch_loader,
commit_loader: commit_loader,
element_loader: element_loader,
Function render
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const {
id,
direction,
part,