• 
      

    Fix cppcheck issues for incorrect language

    Review Request #10067 — Created July 4, 2018 and submitted

    Information

    ReviewBot
    release-1.0.x
    ea10fbe...

    Reviewers

    cppcheck will fallback to C language if it checks a .h file.
    A lot of C++ applications uses .h for C++ header. So cppcheck will
    add issues for C++ only keywords like a "namespace".
    
    This change adds another option to force cppcheck to use
    given language.
    
     
    Description From Last Updated

    E999 SyntaxError: invalid syntax

    reviewbotreviewbot

    E501 line too long (81 > 79 characters)

    reviewbotreviewbot

    E112 expected an indented block

    reviewbotreviewbot

    This isn't a compatibility-breaking change, so we shouldn't change the tool version.

    daviddavid

    Is it likely that this will ever support more? Perhaps we should change this to use a ChoiceField and give …

    daviddavid

    "options" is a funky name for this, because it ends up being turned into a single arg. How about: cppcheck_args …

    daviddavid
    Checks run (1 failed, 1 succeeded)
    flake8 failed.
    JSHint passed.

    flake8

    misery
    david
    1. 
        
    2. bot/reviewbot/tools/cppcheck.py (Diff revision 2)
       
       
      Show all issues

      This isn't a compatibility-breaking change, so we shouldn't change the tool version.

    3. bot/reviewbot/tools/cppcheck.py (Diff revision 2)
       
       
      Show all issues

      Is it likely that this will ever support more? Perhaps we should change this to use a ChoiceField and give it the options "auto-detect", "C", and "C++"

    4. bot/reviewbot/tools/cppcheck.py (Diff revision 2)
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
      Show all issues

      "options" is a funky name for this, because it ends up being turned into a single arg. How about:

      cppcheck_args = [
          'cppcheck',
          '--template=\"{file}::{line}::{severity}::{id}::{message}\"',
          '--enable=%s' % enable_settings,
      ]
      
      lang = settings['force_language'].strip()
      
      if lang:
          cppcheck_args.append('--language=%s' % lang)
      
      cppcheck_args.append(path)
      
      output = execute(cppcheck_args, split_lines=True, ingore_errors=True)
      

      That way future optional things can also be added easily.

    5. 
        
    misery
    david
    1. Ship It!
    2. 
        
    misery
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-1.0.x (870cb33)