descholar-ceo/AnnounceIT

View on GitHub

Showing 26 of 26 total issues

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

resetPswdCheckSecretKeyBtn.addEventListener('click', () => {
    /**
     * Here I check if the the secret key is valid sothat I may know if
     * the account belongs to him/her
     * 
Severity: Major
Found in UI/js/announceit-interactivity.js and 1 other location - About 4 hrs to fix
UI/js/announceit-interactivity.js on lines 11..33

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

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

resetPswdCheckAccBtn.addEventListener('click', () => {
    /**
     *  Here I check if the email exist in database of users
     * if it exists, the server sends the secret key to the user to that email
     * inorder to check this account belongs to him/her, and then 
Severity: Major
Found in UI/js/announceit-interactivity.js and 1 other location - About 4 hrs to fix
UI/js/announceit-interactivity.js on lines 36..58

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

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 announcementsList = announcements.map((announc) => (
    `
    <tr id=${announc.id} key=${announc.id} single-result>
        <td id=${announc.id}>${announc.id}</td>
        <td id=${announc.id}>${announc.title}</td>
Severity: Major
Found in UI/js/display-announcement.js and 1 other location - About 3 hrs to fix
UI/js/search-announcement.js on lines 18..27

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

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

        resultArr = matchings.map((match) => (
    `
    <tr key=${match.id} id=${match.id} single-announcement>
        <td id=${match.id}>${match.id}</td>
        <td id=${match.id}>${match.title}</td>
Severity: Major
Found in UI/js/search-announcement.js and 1 other location - About 3 hrs to fix
UI/js/display-announcement.js on lines 4..13

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

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

    async passwordReset(dataFromTheUser) {
        const { email, oldpassword, newpassword } = dataFromTheUser;
        const isEmailExist = await this.checkIfEmailExistsFromDb(dataFromTheUser);
        if (isEmailExist) {

Severity: Major
Found in server/v2/models/user.js - About 2 hrs to fix

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

            if (changedAnnouncement.length!==0) {
                res.status(200).send({ status: 'success', data: changedAnnouncement[0] });
    
            } else {
                res.status(500).send({ status: 'error', error: 'This is most likely you didn\'t enter a right announcement_ID' });
    Severity: Major
    Found in server/v2/controllers/announcementControllers.js and 2 other locations - About 2 hrs to fix
    server/v2/controllers/announcementControllers.js on lines 36..47
    server/v2/controllers/announcementControllers.js on lines 125..137

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

    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

        if (gottenAnnounc.length !== 0) {
                
                res.status(200).send({
                    status: 'success',
                    data: gottenAnnounc[0]
    Severity: Major
    Found in server/v2/controllers/announcementControllers.js and 2 other locations - About 2 hrs to fix
    server/v2/controllers/announcementControllers.js on lines 125..137
    server/v2/controllers/announcementControllers.js on lines 155..160

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

    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

            if (changedAnnouncement.length!==0) {
                
                res.status(200).send({
                    status: 'success',
                    data: changedAnnouncement[0]
    Severity: Major
    Found in server/v2/controllers/announcementControllers.js and 2 other locations - About 2 hrs to fix
    server/v2/controllers/announcementControllers.js on lines 36..47
    server/v2/controllers/announcementControllers.js on lines 155..160

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

    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

        if (gottenAnnounc.length!==0) {
            res.status(200).send({
                status: 'success',
                data: gottenAnnounc
            });
    Severity: Major
    Found in server/v2/controllers/announcementControllers.js and 1 other location - About 2 hrs to fix
    server/v2/controllers/announcementControllers.js on lines 20..26

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

    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

                if (allMyAnnouncs.length !== 0) {
    
                    res.status(200).send({ status: 'success', data: allMyAnnouncs });
    
                } else {
    Severity: Major
    Found in server/v2/controllers/announcementControllers.js and 1 other location - About 2 hrs to fix
    server/v2/controllers/announcementControllers.js on lines 57..68

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

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

        async passwordReset(dataFromTheUser) {
            const { email, oldpassword, newpassword } = dataFromTheUser;
            const isEmailExist = await this.checkIfEmailExistsFromDb(dataFromTheUser);
            if (isEmailExist) {
    
    
    Severity: Minor
    Found in server/v2/models/user.js - 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 searchingFunc has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const searchingFunc = (searchQuery) => {
        
        let matchings = announcements.filter((announc) => {
            const regex = new RegExp(`^${searchQuery}`, 'gi');
            return announc.status.match(regex) ||
    Severity: Minor
    Found in UI/js/search-announcement.js - About 1 hr to fix

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

      export const validateUserData =async (req, res, next) => {
          const {
              fname, lname, email, phonenumber, address, password
          } = req.body;
      
      
      Severity: Minor
      Found in server/v2/middlewares/validations/validateSignupData.js - About 1 hr to fix

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

            async getSpecificAnnouncementByStatus(announcStatus, userID) {
                const { rows } = await connect
                    .query({ text: GET_ANNOUNCEMENT_BY_STATUS, values: [announcStatus, userID] });
                return rows;
            }
        Severity: Major
        Found in server/v2/models/announcement.js and 2 other locations - About 55 mins to fix
        server/v2/models/announcement.js on lines 47..50
        server/v2/models/announcement.js on lines 72..75

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

            async adminChangeStatusOfAnnouncement(announcId, status) {
                const { rows } = await connect.query({ text: UPDATE_ANNOUNCEMENT_STATUS, values: [status, announcId] });
                return rows;
            }
        Severity: Major
        Found in server/v2/models/announcement.js and 2 other locations - About 55 mins to fix
        server/v2/models/announcement.js on lines 47..50
        server/v2/models/announcement.js on lines 53..57

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

            async getSpecificAnnouncementById(announcID, userID) {
                const { rows } = await connect.query({ text: GET_ANNOUNCEMENT_BY_ID, values: [announcID, userID] });
                return rows;
            }
        Severity: Major
        Found in server/v2/models/announcement.js and 2 other locations - About 55 mins to fix
        server/v2/models/announcement.js on lines 53..57
        server/v2/models/announcement.js on lines 72..75

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

            if (!validateRes.error) {
                next();
            } else {
             res.status(401).send({
                    status:'error',
        Severity: Major
        Found in server/v2/middlewares/validations/validateLoginData.js and 2 other locations - About 55 mins to fix
        server/v2/middlewares/validations/validateAnnouncementData.js on lines 17..24
        server/v2/middlewares/validations/validateSignupData.js on lines 27..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 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 3 locations. Consider refactoring.
        Open

            if (!validationRes.error) {
                next();
            } else {
                res.status(400).send({
                status: 'error',
        Severity: Major
        Found in server/v2/middlewares/validations/validateSignupData.js and 2 other locations - About 55 mins to fix
        server/v2/middlewares/validations/validateAnnouncementData.js on lines 17..24
        server/v2/middlewares/validations/validateLoginData.js on lines 12..19

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

                if (!validateRes.error) {
                    next();
                } else {
                    res.status(400).send({
                status: 'error',
        Severity: Major
        Found in server/v2/middlewares/validations/validateAnnouncementData.js and 2 other locations - About 55 mins to fix
        server/v2/middlewares/validations/validateLoginData.js on lines 12..19
        server/v2/middlewares/validations/validateSignupData.js on lines 27..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 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

            async getAllAnnouncementsByOwnerId(owner) {
                const { rows } = await connect.query({ text: GET_ALL_ANNOUNCEMENTS_FOR_CURRENT_USER, values: [owner] });
                return rows;
            }
        Severity: Minor
        Found in server/v2/models/announcement.js and 1 other location - About 50 mins to fix
        server/v2/models/announcement.js on lines 66..69

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

        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