radar/twist-v2

View on GitHub

Showing 29 of 143 total issues

File types.ts has 1101 lines of code (exceeds 250 allowed). Consider refactoring.
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]> };
Severity: Major
Found in frontend/src/graphql/types.ts - About 2 days to fix

    File tailwind.js has 692 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module.exports = {
      prefix: '',
      important: false,
      separator: ':',
      theme: {
    Severity: Major
    Found in frontend/tailwind.js - About 1 day to fix

      Function ChapterShow has 84 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const ChapterShow = () => {
        const commit: ChapterAtCommitProps = {
          __typename: "Commit",
          bookPermalink: "markdown-book-test",
          bookTitle: "Markdown Book Test",
      Severity: Major
      Found in frontend/src/stories/Chapters/show.stories.tsx - About 3 hrs to fix

        Class ElementProcessor has 28 methods (exceeds 20 allowed). Consider refactoring.
        Open

              class ElementProcessor
                def initialize(chapter, book_path)
                  @chapter = chapter
                  @book_path = book_path
                end
        Severity: Minor
        Found in backend/lib/twist/processors/markdown/element_processor.rb - About 3 hrs to fix

          Function ElementNote has 73 lines of code (exceeds 25 allowed). Consider refactoring.
          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);
          
          
          Severity: Major
          Found in frontend/src/Book/Note/Note.tsx - About 2 hrs to fix

            Class ChapterProcessor has 23 methods (exceeds 20 allowed). Consider refactoring.
            Open

                  class ChapterProcessor
                    include Sidekiq::Worker
            
                    sidekiq_options retry: 0
            
            
            Severity: Minor
            Found in backend/lib/twist/processors/asciidoc/chapter_processor.rb - About 2 hrs to fix

              Function Root has 62 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const Root: React.FC = () => {
                const renderUserInfo = () => {
                  return (
                    <CurrentUserContext.Consumer>
                      {(user: CurrentUserType) =>
              Severity: Major
              Found in frontend/src/App.tsx - About 2 hrs to fix

                Function Comment has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                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);
                Severity: Minor
                Found in frontend/src/Book/Note/Comments/Comment.tsx - About 2 hrs to fix

                  Function Element has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                  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);
                  
                  
                  Severity: Minor
                  Found in frontend/src/Book/Chapter/Element.tsx - About 1 hr to fix

                    Function Form has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                    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>) => {
                    Severity: Minor
                    Found in frontend/src/Book/Chapter/Notes/Form.tsx - About 1 hr to fix

                      Function EditForm has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const EditForm: FunctionComponent<EditFormProps> = (props) => {
                        const { id, originalText, toggleForm } = props;
                        const [text, setText] = useState<string>(props.originalText);
                        const [updateComment] = useMutation(updateCommentMutation);
                      
                      
                      Severity: Minor
                      Found in frontend/src/Book/Note/Comments/EditForm.tsx - About 1 hr to fix

                        Function EditForm has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        const EditForm: FunctionComponent<EditFormProps> = (props) => {
                          const { noteId, originalText, toggleForm } = props;
                          const [text, setText] = useState<string>(props.originalText);
                          const [updateNote] = useMutation(updateNoteMutation);
                        
                        
                        Severity: Minor
                        Found in frontend/src/Book/Note/EditForm.tsx - About 1 hr to fix

                          Function Branch has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const Branch: FunctionComponent<BranchProps> = (props) => {
                            const [updateBranch] = useUpdateBranchMutation({ errorPolicy: "all" });
                            const { bookPermalink, bookTitle, name, commits } = props;
                          
                            const [message, setMessage] = useState<string>("");
                          Severity: Minor
                          Found in frontend/src/Book/Branches/Branch.tsx - About 1 hr to fix

                            Function BooksShow has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export const BooksShow = () => {
                              const commit: Commit = {
                                __typename: "Commit",
                                sha: "abc123",
                                createdAt: "2020-04-15 10:10:10",
                            Severity: Minor
                            Found in frontend/src/stories/Books/show.stories.tsx - About 1 hr to fix

                              Function registerValidSW has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function registerValidSW(swUrl: string, config?: Config) {
                                navigator.serviceWorker
                                  .register(swUrl)
                                  .then(registration => {
                                    registration.onupdatefound = () => {
                              Severity: Minor
                              Found in frontend/src/serviceWorker.ts - About 1 hr to fix

                                Function renderDeleteConfirmation has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  const renderDeleteConfirmation = () => {
                                    if (showDeleteConfirmation) {
                                      return (
                                        <div className="text-red-800 mt-4">
                                          <hr />
                                Severity: Minor
                                Found in frontend/src/Book/Note/Comments/Delete.tsx - About 1 hr to fix

                                  Method handle has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                            def handle(req, res)
                                              # TODO!
                                              # raise "states do not match" if session[:state] != params[:state]
                                              res.format = :json
                                  
                                  
                                  Severity: Minor
                                  Found in backend/lib/twist/web/controllers/oauth/callback.rb - About 1 hr to fix

                                    Function ElementNote has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                    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);
                                    
                                    
                                    Severity: Minor
                                    Found in frontend/src/Book/Note/Note.tsx - About 1 hr 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

                                    Method run has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                            def run(query:, variables: {}, context: {})
                                              context = context.merge(
                                                branch_loader: branch_loader,
                                                commit_loader: commit_loader,
                                                element_loader: element_loader,
                                    Severity: Minor
                                    Found in backend/lib/twist/web/graphql/runner.rb - About 1 hr to fix

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

                                        render() {
                                          const {
                                            id,
                                            direction,
                                            part,
                                      Severity: Minor
                                      Found in frontend/src/Book/Chapter/Link.tsx - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language