dart-code-checker / dart-code-metrics

Software analytics tool that helps developers analyse and improve software quality.
https://dcm.dev
Other
856 stars 262 forks source link

[Change request] (Add other lint rules) #1226

Closed Nana-Kwame-bot closed 1 year ago

Nana-Kwame-bot commented 1 year ago

DCM version

v5.7.2

What problem do you want to solve?

Ideally I wanted this to be a question but is it possible to add other lint rules from other packages like flutter_lints or very_good_analysis? This package has some good lints but others important to me like use_super_parameters are not available. I tried using very_good_analysis in the analysis_options.yaml file as well but I think I just broke the analysis server instead. I checked out the teams version and although the plugin has its own analysis server, you still have to add the package to analysis_options.yaml. I'm I doing it wrong or is it not possible to use other linting packages or other lint rules?

What do you think is the correct solution?

I'd like DCM to be usable with other linting packages. The number of rules I want to suggest are over 50 and it doesn't make sense to create an issue for each of them.

Participation

Additional comments

If it's not possible, that's okay I'll just stick with very_good_analysis. Perhaps those rules will be added in future updates. I'm just asking.

incendial commented 1 year ago

@Nana-Kwame-bot this package provides custom lint rules that are not available in other package, but also does not define any configuration for the standard rules set. You can use both our rules and any standard in a single analysis_options.yaml.

I tried using very_good_analysis in the analysis_options.yaml file as well but I think I just broke the analysis server instead.

Can you share the analysis_options file after you've added all the lints you want? It 100% possible to use them all, here is the examples: https://github.com/MewsSystems/mews-flutter/blob/master/mews_pedantic/lib/analysis_options.yaml and https://github.com/ChiliLabs/chili-flutter-analysis/blob/main/lib/analysis_options.0.0.1.yaml.

Nana-Kwame-bot commented 1 year ago

@Nana-Kwame-bot this package provides custom lint rules that are not available in other package, but also does not define any configuration for the standard rules set. You can use both our rules and any standard in a single analysis_options.yaml.

I tried using very_good_analysis in the analysis_options.yaml file as well but I think I just broke the analysis server instead.

Can you share the analysis_options file after you've added all the lints you want? It 100% possible to use them all, here is the examples: https://github.com/MewsSystems/mews-flutter/blob/master/mews_pedantic/lib/analysis_options.yaml and https://github.com/ChiliLabs/chili-flutter-analysis/blob/main/lib/analysis_options.0.0.1.yaml.

This is my implementation, gist. Not sure what I did wrong here to cause analysis to fail but it simply was not working for the dcm side. I'll check out the other ones, perhaps I did a simple mistake

incendial commented 1 year ago

Can you remove this one empty line https://gist.github.com/Nana-Kwame-bot/ae3d61578b8bf39f22c256da2da33313#file-analysis_options-yaml-L21? But other than that is looks okay. If removing it won't work, can you check the examples I've mentioned earlier?

Nana-Kwame-bot commented 1 year ago

I've found the issue. I think it's because I'm using multiple lints very_good_analysis and dcm but the analyzer is very slow when I do. It works but takes 5 mins to show any warnings/errors in the IDE. Anything I can do to alleviate this? My PC is not that slow 16 gb ram and 2.2ghz core i7. Also will getting the teams version help in any way?

incendial commented 1 year ago

It works but takes 5 mins to show any warnings/errors in the IDE.

That's a huge number, how large is your codebase?

Also will getting the teams version help in any way?

It should.

Nana-Kwame-bot commented 1 year ago

That's a huge number, how large is your codebase?

It's a new project just about 20 files.

Trying it with other projects the time seems consistent like it's not dependent on the size of the codebase.

incendial commented 1 year ago

Something is really off. Can you show what dart info and code --status output is? But make sure no sencetive data is there.

Nana-Kwame-bot commented 1 year ago

dart info

`If providing this information as part of reporting a bug, please review the information below to ensure it only contains things you're comfortable posting publicly.

General info

Project info

Process info

Memory CPU Elapsed time Command line
56 MB 0.0% 03:45 dart devtools --machine --try-ports 10 --allow-embedding
56 MB 0.0% 02:54 dart devtools --machine --try-ports 10 --allow-embedding
446 MB 0.0% 02:54 dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.62.0
95 MB 0.0% 03:45 flutter_tools.snapshot daemon
99 MB 0.7% 02:54 flutter_tools.snapshot daemon `

code --status

`bootstrap_check_in(): (os/kern) unknown error code (44c)

Version: Code 1.77.3 (704ed70d4fd1c6bd6342c436f1ede30d1cff4710, 2023-04-12T09:19:37.325Z) OS Version: Darwin x64 21.6.0 CPUs: Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz (8 x 2200) Memory (System): 16.00GB (6.02GB free) Load (avg): 2, 3, 4 VM: 0% Screen Reader: no Process Argv: --crash-reporter-id ed56b46b-4004-4649-a84b-fe6c44d21ee8 GPU Status: 2d_canvas: enabled canvas_oop_rasterization: disabled_off direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled metal: disabled_off multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_renderer: enabled_on video_decode: enabled video_encode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: disabled_off

CPU % Mem MB PID Process 6 164 4748 code main 2 66 4751 gpu-process 0 33 4752 utility-network-service 10 360 4754 window [1] (analysis_options.yaml — dcsa) 0 147 4763 shared-process 0 49 4766 ptyHost 0 0 5038 /bin/zsh -il 0 0 5476 bash /usr/local/bin/code --status 4 33 5485 electron-nodejs (/Applications/Visual Studio Code.app/Contents/MacOS/Electron /Applications/Visual Studio Code.app/Contents/Resources/app/out/cli.js --ms-enable-electron-run-as-node --status) 0 0 5494 (ps) 0 49 4764 fileWatcher [1] 2 360 4765 extensionHost [1] 0 98 4772 electron-nodejs (config.js ) 0 0 4850 /usr/bin/script -t 0 /dev/null xcrun xcdevice observe --both 0 33 4851 /Applications/Xcode.app/Contents/Developer/usr/bin/xcdevice observe --both 0 49 4773 /usr/local/Caskroom/flutter/bin/cache/dart-sdk/bin/dart devtools --machine --try-ports 10 --allow-embedding 0 442 4774 /usr/local/Caskroom/flutter/bin/cache/dart-sdk/bin/dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.62.0 0 66 4808 electron-nodejs (/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) --ms-enable-electron-run-as-node /Users/user/.vscode/extensions/kisstkondoros.vscode-gutter-preview-0.30.0/dist/server.js --node-ipc --clientProcessId=4765) 0 82 4871 electron-nodejs (/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) --ms-enable-electron-run-as-node /Users/user/.vscode/extensions/redhat.vscode-yaml-1.12.2/dist/languageserver.js --node-ipc --clientProcessId=4765) 0 115 4890 electron-nodejs (/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) --ms-enable-electron-run-as-node /Users/user/.vscode/extensions/ms-python.vscode-pylance-2023.4.30/dist/server.bundle.js --cancellationReceive=file:072e309ef23c76df2c5e125e8b2464ac1b6cadfd28 --node-ipc --clientProcessId=4765) 0 98 4905 electron-nodejs (/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) --ms-enable-electron-run-as-node /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/json-language-features/server/dist/node/jsonServerMain --node-ipc --clientProcessId=4765)

Workspace Stats: | Window (analysis_options.yaml — dcsa) | Folder (dcsa): more than 20147 files | File types: h(4517) d(2082) dia(2078) o(2068) pcm(1261) timestamp(1008) | c(554) cc(502) grpc_back(474) m(390) | Conf files:`

incendial commented 1 year ago

Everything looks fine, even memory and CPU usages are pretty good.

incendial commented 1 year ago

Can you try removing .dartServer (https://github.com/dart-code-checker/dart-code-metrics/blob/master/CONTRIBUTING.md#run-the-plugin-in-ide, 5th step) and then reload the IDE?

Note, this is the cache of the analyzer, so it will make the next run or two a bit slower.

incendial commented 1 year ago

If this does not help, I can give a Teams trial to test if it will work any different.

Nana-Kwame-bot commented 1 year ago

If this does not help, I can give a Teams trial to test if it will work any different.

I already have it.

Can you try removing .dartServer (https://github.com/dart-code-checker/dart-code-metrics/blob/master/CONTRIBUTING.md#run-the-plugin-in-ide, 5th step) and then reload the IDE?

This works on Vscode thanks but not for android studio. In the DCM tab at the bottom the warnings show up but not i the IDE like with vscode.

incendial commented 1 year ago

In the DCM tab at the bottom the warnings show up but not i the IDE like with vscode.

Wait, this tab is for the Teams version. So do you try to use the plugin or the Teams version?

Nana-Kwame-bot commented 1 year ago

The teams version. I've taken the plugin out for the trial

incendial commented 1 year ago

Then why do you have the plugin enabled here https://gist.github.com/Nana-Kwame-bot/ae3d61578b8bf39f22c256da2da33313#file-analysis_options-yaml-L14? Do you have DCM VS Code extension installed?

Also please if you have the Teams version, email me instead. This repo is for the plugin version.

Nana-Kwame-bot commented 1 year ago

That gist is old and I changed it yesterday. I have the vscode extension but my issue is with android studio.

incendial commented 1 year ago

Can you try the same plugin in IntelliJ?

Nana-Kwame-bot commented 1 year ago

Can you try the same plugin in IntelliJ?

I have the plugin installed on Android Studio. It's was just very slow, after a while it was okay. I'm good now, thanks.

incendial commented 1 year ago

I asked to try IntelliJ to understand whether the problem is related only to Android Studio or not. I mainly test it in IntelliJ and everything is fine performance-wise which makes me wonder what's different in your setup.

So if you encounter this again, please test it in IntelliJ.