Skip to content

Make vscode a bit nicer [fewer spurious warnings or errors] #940

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

Merged
merged 1 commit into from
Jul 13, 2025

Conversation

sbryngelson
Copy link
Member

@sbryngelson sbryngelson commented Jul 13, 2025

User description

Modifications to the vscode setup to make the linter somewhat useful (and surpress the bazillion warnings and errorrs that were spurious)


PR Type

Enhancement


Description

  • Configure fortls language server for Fortran development

  • Disable built-in VSCode Fortran linter warnings

  • Add comprehensive error suppression configuration

  • Update workspace settings for better development experience


Changes diagram

flowchart LR
  A["VSCode Settings"] --> B["Disable Built-in Linter"]
  A --> C["Enable fortls Server"]
  D["fortls Config"] --> E["Source Directories"]
  D --> F["Error Suppression"]
  D --> G["External Modules"]
  B --> H["Cleaner Development"]
  C --> H
  F --> H
Loading

Changes walkthrough 📝

Relevant files
Configuration changes
.fortls.json
Add fortls language server configuration                                 

.fortls.json

  • Configure fortls language server with source directories and include
    paths
  • Define preprocessor settings for MFC project
  • Disable diagnostics and enable comprehensive error suppression
  • Specify external modules and build directories
  • +94/-0   
    .fortlsrc
    Add alternative fortls configuration file                               

    .fortlsrc

  • Similar fortls configuration with different diagnostic settings
  • Enable debug logging and reduce error suppression list
  • Add additional excluded paths for NVTX and syscheck files
  • Configure line length limits and variable diagnostics
  • +96/-0   
    extensions.json
    Disable unwanted Fortran extension recommendations             

    .vscode/extensions.json

  • Move gfortran linter from recommendations to unwanted recommendations
  • Clear recommendations array to prevent automatic extension suggestions
  • +2/-1     
    settings.json
    Configure VSCode workspace for fortls integration               

    .vscode/settings.json

  • Disable built-in Fortran linter and enable fortls language server
  • Add comprehensive file exclusions for misc, benchmarks, examples,
    tests
  • Configure editor settings with 2-space tabs and semantic highlighting
    disabled
  • Set up workspace-specific Python interpreter path and file
    associations
  • +74/-10 

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • @Copilot Copilot AI review requested due to automatic review settings July 13, 2025 22:40
    Copy link
    Contributor

    @Copilot Copilot AI left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Pull Request Overview

    This PR refines the VS Code workspace and FortLS configuration to suppress spurious warnings and errors, streamline editor settings, and enforce the FortLS language server.

    • Update editor indentation, rulers, and file exclusion patterns
    • Disable built-in Fortran linting features and enable only FortLS
    • Add two FortLS configuration files with project-specific paths and suppression lists

    Reviewed Changes

    Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

    File Description
    .vscode/settings.json Adjusted tab size, file excludes, Fortran linter and language-server settings
    .vscode/extensions.json Cleared recommendations and added unwanted extension
    .fortlsrc New FortLS config with source, include, mod, and exclusion paths
    .fortls.json New FortLS JSON config mirroring .fortlsrc settings
    Comments suppressed due to low confidence (3)

    .vscode/settings.json:31

    • The setting fortran.disabled may not exist in the extension's schema. Verify and use the correct keys from the Fortran extension documentation to disable built-in features.
        "fortran.disabled": false,
    

    .vscode/settings.json:68

    • Ensure the language identifier matches VS Code's actual Fortran free-form ID (often fortran-freeform) so these editor settings are applied correctly.
        "[FortranFreeForm]": {
    

    .fortls.json:1

    • You have both .fortlsrc and .fortls.json with overlapping settings. Consolidate to a single config file to avoid confusion and potential conflicts.
    {
    

    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Duplicate Code

    The .fortls.json and .fortlsrc files contain nearly identical configurations with only minor differences in diagnostic settings and error suppression lists. This duplication makes maintenance difficult and could lead to configuration drift.

    {
        "source_dirs": [
            "src/",
            "src/common/",
            "src/simulation/",
            "src/pre_process/",
            "src/post_process/"
        ],
        "excl_paths": [
            "benchmarks/",
            "examples/",
            "tests/",
            "misc/",
            "src/pre_process/include/2dHardcodedIC.fpp",
            "src/pre_process/include/3dHardcodedIC.fpp",
            "src/pre_process/include/ExtrusionHardcodedIC.fpp"
        ],
        "include_dirs": [
            "src/common/include/",
            "src/simulation/include/",
            "src/pre_process/include/",
            "src/post_process/include/"
        ],
        "pp_suffixes": [".fpp"],
        "pp_defs": {
            "MFC": 1,
            "MFC_DOUBLE_PRECISION": 1
        },
        "lowercase_intrinsics": true,
        "debug_log": false,
        "disable_diagnostics": true,
        "use_signature_help": true,
        "variable_hover": true,
        "hover_signature": true,
        "enable_code_actions": true,
        "mod_dirs": [
            "build/pre_process/",
            "build/simulation/",
            "build/post_process/",
            "build/common/"
        ],
        "ext_mod_dirs": [
            "/usr/include/",
            "/usr/local/include/",
            "/opt/homebrew/include/"
        ],
        "implicit_external_mods": [
            "mpi",
            "m_thermochem",
            "hipfort",
            "hipfort_check",
            "hipfort_hipfft",
            "cutensorex",
            "silo_f9x",
            "m_model"
        ],
        "disable_diagnostics_for_external_modules": true,
        "max_line_length": 132,
        "symbol_skip_mem": [
            "mpi_*"
        ],
        "disable_var_diagnostics": true,
        "disable_fypp": false,
        "fypp_strict": false,
        "error_suppression_list": [
            "include-not-found",
            "mod-not-found",
            "var-masking",
            "declared-twice",
            "no-matching-declaration",
            "invalid-parent",
            "parsing-error",
            "fypp-error",
            "preprocessor-error",
            "syntax-error",
            "semantic-error",
            "type-error",
            "undefined-variable",
            "line-too-long"
        ],
        "incremental_sync": false,
        "debug_parser": false,
        "skip_parse_errors": true,
        "disable_parser": [
            "src/post_process/m_data_output.fpp",
            "src/pre_process/include/ExtrusionHardcodedIC.fpp",
            "src/pre_process/m_checker.fpp",
            "src/pre_process/include/2dHardcodedIC.fpp",
            "src/pre_process/include/3dHardcodedIC.fpp",
            "src/simulation/m_qbmm.fpp",
            "src/common/m_variables_conversion.fpp",
            "src/simulation/m_global_parameters.fpp"
        ]
    } 
    Overly Broad Suppression

    The error_suppression_list contains critical error types like "syntax-error", "semantic-error", "type-error", and "undefined-variable" which could hide real bugs and make debugging difficult.

    "error_suppression_list": [
        "include-not-found",
        "mod-not-found",
        "var-masking",
        "declared-twice",
        "no-matching-declaration",
        "invalid-parent",
        "parsing-error",
        "fypp-error",
        "preprocessor-error",
        "syntax-error",
        "semantic-error",
        "type-error",
        "undefined-variable",
        "line-too-long"
    ],
    Configuration Redundancy

    Multiple overlapping settings for disabling Fortran linter features and file exclusions are scattered throughout the configuration, making it unclear which settings are actually effective.

        "fortran.disabled": false,
        "fortran.linter.enabled": false,
        "fortran.linter.gfortran.enabled": false,
        "fortran.linter.compiler": "",
        "fortran.linter.diagnostics": false,
        "fortran.linter.gfortran.diagnostics": false,
        "fortran.linter.modOutput": "",
        "fortran.linter.includePaths": [],
        "fortran.linter.extraArgs": [],
        "fortran.provideDiagnostics": false,
        "fortran.provideCompletion": false,
        "fortran.provideHover": false,
        "fortran.provideSymbols": false,
        "fortran.validation.enabled": false,
        "fortran.validation.diagnostics": false,
        "fortran.symbols": false,
        "fortran.hover": false,
    
        // Enable ONLY fortls language server
        "fortran.enableLanguageServer": true,
        "fortran.languageServer": "fortls",
        "fortran.fortls.disabled": false,
        "fortran.fortls.path": "fortls",
    
        // Try to disable any built-in language features
        "editor.semanticHighlighting.enabled": false,
        "editor.suggest.showWords": false,
        "editor.suggest.showSnippets": false,
    
        "[fortran]": {
            "editor.tabSize": 2,
            "editor.semanticHighlighting.enabled": false
        },
        "[fortran-free]": {
            "editor.tabSize": 2,
            "editor.semanticHighlighting.enabled": false
        },
        "[FortranFreeForm]": {
            "editor.tabSize": 2,
            "editor.semanticHighlighting.enabled": false
        },
    
        // File exclusions - multiple layers of exclusion
        "files.watcherExclude": {
            "**/misc/**": true,
            "**/benchmarks/**": true,
            "**/examples/**": true,
            "**/tests/**": true,
            "**/build/**": true,
            "**/m_nvtx*": true,
            "**/syscheck.fpp": true
        },
    
        "search.exclude": {
            "**/misc/**": true,
            "**/benchmarks/**": true,
            "**/examples/**": true,
            "**/tests/**": true,
            "**/build/**": true
        },
    
        // Keep problems panel available
        "problems.showOn": "toggle",
        "problems.defaultViewMode": "list"
    }

    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Reduce excessive error suppression

    Suppressing all error types including critical ones like "syntax-error" and
    "semantic-error" defeats the purpose of a language server. Consider keeping only
    non-critical errors in the suppression list while allowing important syntax and
    semantic errors to be reported.

    .fortls.json [65-80]

     "error_suppression_list": [
         "include-not-found",
         "mod-not-found",
         "var-masking",
         "declared-twice",
    -    "no-matching-declaration",
    -    "invalid-parent",
    -    "parsing-error",
    -    "fypp-error",
    -    "preprocessor-error",
    -    "syntax-error",
    -    "semantic-error",
    -    "type-error",
    -    "undefined-variable",
         "line-too-long"
     ]
    Suggestion importance[1-10]: 9

    __

    Why: The suggestion correctly identifies that suppressing critical errors like syntax-error and semantic-error undermines the purpose of a language server, and this change significantly improves the tool's utility.

    High
    • More

    @sbryngelson sbryngelson merged commit aefe26d into MFlowCode:master Jul 13, 2025
    18 checks passed
    @sbryngelson sbryngelson deleted the vscode branch July 14, 2025 14:37
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Development

    Successfully merging this pull request may close these issues.

    1 participant