aleksandrchusovitin/frontend-project-lvl4

View on GitHub

Showing 26 of 26 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  return (
    <>
      <Modal.Header>
        <Modal.Title>{t('modals.renameChannel.header')}</Modal.Title>
        <button
Severity: Major
Found in src/components/modals/RenameChannel.jsx and 1 other location - About 2 days to fix
src/components/modals/AddChannel.jsx on lines 56..96

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 359.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  return (
    <>
      <Modal.Header>
        <Modal.Title>{t('modals.addChannel.header')}</Modal.Title>
        <button
Severity: Major
Found in src/components/modals/AddChannel.jsx and 1 other location - About 2 days to fix
src/components/modals/RenameChannel.jsx on lines 54..94

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 359.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              const handleRenameChannel = (id, name, action) => async (e) => {
                e.preventDefault();
                dispatch(channelWithActionUpdated({ id, name }));
                dispatch(openModal(action));
              };
            Severity: Major
            Found in src/components/Channels.jsx and 1 other location - About 1 hr to fix
            src/components/Channels.jsx on lines 30..34

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 62.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              const handleRemoveChannel = (id, name, action) => async (e) => {
                e.preventDefault();
                dispatch(channelWithActionUpdated({ id, name }));
                dispatch(openModal(action));
              };
            Severity: Major
            Found in src/components/Channels.jsx and 1 other location - About 1 hr to fix
            src/components/Channels.jsx on lines 36..40

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 62.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                    const state = {
                      channels: [
                        { id: 100, name: 'custom', removable: true },
                      ],
                      messages: [
                  Severity: Minor
                  Found in __tests__/messages.test.js and 1 other location - About 55 mins to fix
                  __tests__/messages.test.js on lines 8..15

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 54.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                    const state = {
                      channels: [
                        { id: 100, name: 'custom', removable: true },
                      ],
                      messages: [
                  Severity: Minor
                  Found in __tests__/messages.test.js and 1 other location - About 55 mins to fix
                  __tests__/messages.test.js on lines 39..46

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 54.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                                    <Form.Control.Feedback type="invalid" tooltip placement="right">
                                      {formik.errors.password}
                                    </Form.Control.Feedback>
                  Severity: Minor
                  Found in src/pages/SignUp.jsx and 1 other location - About 55 mins to fix
                  src/pages/SignUp.jsx on lines 97..99

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 53.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                                    <Form.Control.Feedback type="invalid" tooltip placement="right">
                                      {formik.errors.username}
                                    </Form.Control.Feedback>
                  Severity: Minor
                  Found in src/pages/SignUp.jsx and 1 other location - About 55 mins to fix
                  src/pages/SignUp.jsx on lines 120..122

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 53.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                      {
                        type: 'channels',
                        id: expect.any(Number),
                        attributes: {
                          id: expect.any(Number), name: 'general', removable: false,
                  Severity: Minor
                  Found in __tests__/channels.test.js and 1 other location - About 40 mins to fix
                  __tests__/channels.test.js on lines 23..29

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 49.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                    expect(JSON.parse(response.payload)).toEqual(
                      expect.objectContaining({
                        data: expect.arrayContaining(messages),
                      }),
                    );
                  Severity: Minor
                  Found in __tests__/messages.test.js and 1 other location - About 40 mins to fix
                  __tests__/channels.test.js on lines 31..35

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 49.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Severity
                  Category
                  Status
                  Source
                  Language