aleksandrchusovitin/frontend-project-lvl4

View on GitHub

Showing 10 of 26 total issues

Function SignUp has 140 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const SignUp = () => {
  const [registrationFailed, setRegistrationFailed] = useState(false);
  const usernameInputRef = useRef(null);
  const { t } = useTranslation();
  const navigate = useNavigate();
Severity: Major
Found in src/pages/SignUp.jsx - About 5 hrs to fix

    Function LoginPage has 110 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const LoginPage = () => {
      const [authFailed, setAuthFailed] = useState(false);
      const location = useLocation();
      const navigate = useNavigate();
      const usernameInputRef = useRef(null);
    Severity: Major
    Found in src/pages/Login.jsx - About 4 hrs to fix

      Function Channels has 72 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const Channels = () => {
        const { t } = useTranslation();
        const dispatch = useDispatch();
        const channels = useSelector(getChannels);
        const currentChannelId = useSelector(getCurrentChannelId);
      Severity: Major
      Found in src/components/Channels.jsx - About 2 hrs to fix

        Function SubmitMessage has 69 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const SubmitMessage = () => {
          const addMessageInputRef = useRef(null);
          const { t } = useTranslation();
          const auth = useAuth();
          const socket = useSocket();
        Severity: Major
        Found in src/components/SubmitMessage.jsx - About 2 hrs to fix

          Function SignUp has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          const SignUp = () => {
            const [registrationFailed, setRegistrationFailed] = useState(false);
            const usernameInputRef = useRef(null);
            const { t } = useTranslation();
            const navigate = useNavigate();
          Severity: Minor
          Found in src/pages/SignUp.jsx - 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

          Function Chat has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const Chat = () => {
            const messagesBoxRef = useRef(null);
            const { t } = useTranslation();
          
            useEffect(() => {
          Severity: Minor
          Found in src/components/Chat.jsx - About 1 hr to fix

            Function LoginPage has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            const LoginPage = () => {
              const [authFailed, setAuthFailed] = useState(false);
              const location = useLocation();
              const navigate = useNavigate();
              const usernameInputRef = useRef(null);
            Severity: Minor
            Found in src/pages/Login.jsx - 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

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

            const MainPage = () => {
              const auth = useAuth();
            
              const headers = auth.getAuthHeader();
              const { t } = useTranslation();
            Severity: Minor
            Found in src/pages/MainPage.jsx - About 1 hr to fix

              Function renderChannelsList has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                const renderChannelsList = (channelsData) => {
                  const renderGeneralButton = (id, name, isCurrentChannel) => {
                    const classNameGeneralButton = cn('w-100 rounded-0 text-start btn', { 'btn-secondary': isCurrentChannel });
                    return (
                      <button type="button" className={classNameGeneralButton} onClick={handleChangeChannel(id)}>
              Severity: Minor
              Found in src/components/Channels.jsx - About 1 hr to fix

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

                const buildState = (defaultState) => {
                  const generalChannelId = getNextId();
                  const randomChannelId = getNextId();
                  const state = {
                    channels: [
                Severity: Minor
                Found in server/routes.js - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language