redaktorscha/frontend-project-12

View on GitHub

Showing 31 of 31 total issues

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

    try {
      setSignupError('');
      const response = await axios.post(apiRoute, formData);
      const { data } = response;
      if (data) {
Severity: Major
Found in frontend/src/components/Signup.jsx and 1 other location - About 6 hrs to fix
frontend/src/components/Login.jsx on lines 53..72

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 164.

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

    try {
      setLoginError('');
      const response = await axios.post(apiRoute, formData);
      const { data } = response;
      if (data) {
Severity: Major
Found in frontend/src/components/Login.jsx and 1 other location - About 6 hrs to fix
frontend/src/components/Signup.jsx on lines 63..82

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 164.

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 SignupForm has 157 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const SignupForm = () => {
  const { t } = useTranslation();
  const navigate = useNavigate();
  const { logIn } = useAuth();
  const rollbar = useRollbar();
Severity: Major
Found in frontend/src/components/Signup.jsx - About 6 hrs to fix

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

        await addNewChannel(newChannel)
          .then(() => {
            handleCloseModal();
            setFormSubmitting(false);
            toast.success(t('toasts.channelCreated'));
    Severity: Major
    Found in frontend/src/components/modals/AddChannelModal.jsx and 2 other locations - About 5 hrs to fix
    frontend/src/components/modals/DeleteChannelModal.jsx on lines 41..55
    frontend/src/components/modals/RenameChannelModal.jsx on lines 43..56

    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 140.

    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 3 locations. Consider refactoring.
    Open

          await renameChannel(renamedChannel).then(() => {
            handleCloseModal();
            setFormSubmitting(false);
            toast.success(t('toasts.channelRenamed'));
          })
    Severity: Major
    Found in frontend/src/components/modals/RenameChannelModal.jsx and 2 other locations - About 5 hrs to fix
    frontend/src/components/modals/AddChannelModal.jsx on lines 34..48
    frontend/src/components/modals/DeleteChannelModal.jsx on lines 41..55

    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 140.

    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 3 locations. Consider refactoring.
    Open

          await removeChannel(channelForDeletion)
            .then(() => {
              handleCloseModal();
              setIsSubmitting(false);
              toast.success(t('toasts.channelDeleted'));
    Severity: Major
    Found in frontend/src/components/modals/DeleteChannelModal.jsx and 2 other locations - About 5 hrs to fix
    frontend/src/components/modals/AddChannelModal.jsx on lines 34..48
    frontend/src/components/modals/RenameChannelModal.jsx on lines 43..56

    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 140.

    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 LoginForm has 124 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const LoginForm = () => {
      const { t } = useTranslation();
      const navigate = useNavigate();
      const { logIn } = useAuth();
      const rollbar = useRollbar();
    Severity: Major
    Found in frontend/src/components/Login.jsx - About 4 hrs to fix

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

                  <Form.Control
                    type="password"
                    name="confirmPassword"
                    autoComplete="off"
                    required
      Severity: Major
      Found in frontend/src/components/Signup.jsx and 1 other location - About 4 hrs to fix
      frontend/src/components/Signup.jsx on lines 134..145

      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 123.

      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
                    type="password"
                    name="password"
                    autoComplete="off"
                    required
      Severity: Major
      Found in frontend/src/components/Signup.jsx and 1 other location - About 4 hrs to fix
      frontend/src/components/Signup.jsx on lines 156..167

      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 123.

      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 addChannelSchema = yup
          .object()
          .shape({
            channelName: yup
              .string()
      Severity: Major
      Found in frontend/src/components/modals/AddChannelModal.jsx and 1 other location - About 2 hrs to fix
      frontend/src/components/modals/RenameChannelModal.jsx on lines 66..76

      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 93.

      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 renameChannelSchema = yup
          .object()
          .shape({
            channelName: yup
              .string()
      Severity: Major
      Found in frontend/src/components/modals/RenameChannelModal.jsx and 1 other location - About 2 hrs to fix
      frontend/src/components/modals/AddChannelModal.jsx on lines 56..66

      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 93.

      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 RenameChannelModal has 71 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const RenameChannelModal = () => {
        const { renameChannel } = useChatApi();
        const dispatch = useDispatch();
        const { t } = useTranslation();
        const { handleClose } = modalActions;
      Severity: Major
      Found in frontend/src/components/modals/RenameChannelModal.jsx - About 2 hrs to fix

        Function DeleteChannelModal has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const DeleteChannelModal = () => {
          const { removeChannel } = useChatApi();
          const [isSubmitting, setIsSubmitting] = useState(false);
          const dispatch = useDispatch();
          const { t } = useTranslation();
        Severity: Major
        Found in frontend/src/components/modals/DeleteChannelModal.jsx - About 2 hrs to fix

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

          const Chat = () => {
            const [isLoading, setIsLoading] = useState(true);
            const { user, logOut } = useAuth();
            const { t } = useTranslation();
          
          
          Severity: Major
          Found in frontend/src/components/Chat.jsx - About 2 hrs to fix

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

              const sendMessage = async (payload) => new Promise((resolve, reject) => {
                socketClient.timeout(3000).emit('newMessage', payload, (error) => {
                  if (error) {
                    reject(new Error('network error'));
                    return;
            Severity: Major
            Found in frontend/src/init.jsx and 2 other locations - About 1 hr to fix
            frontend/src/init.jsx on lines 57..65
            frontend/src/init.jsx on lines 72..80

            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 74.

            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 3 locations. Consider refactoring.
            Open

              const renameChannel = async (payload) => new Promise((resolve, reject) => {
                socketClient.timeout(3000).emit('renameChannel', payload, (error) => {
                  if (error) {
                    reject(new Error('network error'));
                    return;
            Severity: Major
            Found in frontend/src/init.jsx and 2 other locations - About 1 hr to fix
            frontend/src/init.jsx on lines 26..34
            frontend/src/init.jsx on lines 72..80

            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 74.

            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 3 locations. Consider refactoring.
            Open

              const removeChannel = async (payload) => new Promise((resolve, reject) => {
                socketClient.timeout(3000).emit('removeChannel', payload, (error) => {
                  if (error) {
                    reject(new Error('network error'));
                    return;
            Severity: Major
            Found in frontend/src/init.jsx and 2 other locations - About 1 hr to fix
            frontend/src/init.jsx on lines 26..34
            frontend/src/init.jsx on lines 57..65

            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 74.

            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 LoginForm has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            const LoginForm = () => {
              const { t } = useTranslation();
              const navigate = useNavigate();
              const { logIn } = useAuth();
              const rollbar = useRollbar();
            Severity: Minor
            Found in frontend/src/components/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 SignupForm has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            const SignupForm = () => {
              const { t } = useTranslation();
              const navigate = useNavigate();
              const { logIn } = useAuth();
              const rollbar = useRollbar();
            Severity: Minor
            Found in frontend/src/components/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 Sidebar has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const Sidebar = () => {
              const { t } = useTranslation();
              const dispatch = useDispatch();
              const [btnFocused, setBtnFocused] = useState(false);
              const { type } = useSelector((state) => state.modal);
            Severity: Minor
            Found in frontend/src/components/Sidebar.jsx - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language