Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore rule matches in comments #272

Closed
jonathan-terrell opened this issue Sep 14, 2024 · 2 comments
Closed

Ignore rule matches in comments #272

jonathan-terrell opened this issue Sep 14, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@jonathan-terrell
Copy link

Describe the bug
Detector does not ignore comments. In my case it identified the word 'if' within a comment as an 'if' statement and as a result reported a cyclomatic complexity error ("Cyclomatic complexity is high (6)").

To Reproduce
Run the detector on the following comment:

// 'src/global.ts' provides helpers for communicating with the application monitor. These are required as it may not have completed loading if we access it during the startup process.". 
  1. What is the exact code you are analyzing?
// Dependencies - Vendor
import { createApp } from 'vue';
import { createPinia } from 'pinia';
import { VueQueryPlugin } from '@tanstack/vue-query';

// Dependencies - Framework
import '@/assets/main.scss'; // Global application styles.
import { initTranslations } from '@/locales';
import router from '@/router';
import { handleError, initAppMonitor } from '@/globals';

// Dependencies - Component
import App from '@/App.vue'; // Root component.

// Application - Initialise
try {
    // Create a new Vue application instance and register plugins.
    const application = createApp(App); // Create the main Vue instance using the root component.
    application.use(createPinia()); // Register Pinia for centralized state management. 'useMainStore' in 'src/stores/mainStore.ts' is then available for use.
    application.use(VueQueryPlugin); // Register Vue Query for managing data fetching, caching, and synchronization.
    application.use(router); // Register the router instance to handle navigation.

    // Initialize translations before proceeding with application initialization.
    initTranslations(application).then(() => {
        try {
            // Asynchronously load and initialize the application monitor without blocking application startup.
            // 'src/global.ts' provides helpers for communicating with the application monitor. These are required as the monitor may not have completed loading if we access it during the startup process.
            // The application monitor is also responsible for asynchronously loading the session manager.
            import('@/appMonitor').then((module) => initAppMonitor(module));

            application.mount('#app'); // Mount the application to the DOM. This will begin before the application monitor and session manager have completed loading.
        } catch (error) {
            handleError(error, { locator: 'Application Initialisation [main.2]' }); // Report error during initialisation.
        }
    });
} catch (error) {
    handleError(error, { locator: 'Application Initialisation [main.1]' }); // Report error during initialisation.
}

  1. What is the output you are getting?

Expected behavior
No cyclomatic complexity error/warning. I would expect the detector to ignore comments.

Screenshots

Used version number of vue-mess-detector:
v0.48.0

Used version number of node & yarn:
node:v20.15.0
npm: 10.8.2

Additional context
As discussed on Discord.

@jonathan-terrell jonathan-terrell added the bug Something isn't working label Sep 14, 2024
@rrd108 rrd108 changed the title Do no treat 'if' in comment as 'if' statement Ignore matches in comments Sep 14, 2024
@rrd108
Copy link
Owner

rrd108 commented Sep 14, 2024

Actually it should be true to all rules. All comments should be ignored by the rule reporter.

So I changed the issue title.


Something slightly related.
@David-Pena what do you think adding a new rule what checks the amount of comments. I guess we have to discuss it on discord,.

@rrd108 rrd108 changed the title Ignore matches in comments Ignore rule matches in comments Sep 14, 2024
@rrd108 rrd108 closed this as completed in 2452797 Sep 16, 2024
@rrd108
Copy link
Owner

rrd108 commented Sep 16, 2024

it should be released tomorrow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants