Page MenuHomePhabricator

Use `cppcheck` to lint XHPAST source
ClosedPublic

Authored by joshuaspence on Apr 4 2015, 5:17 AM.
Tags
None
Referenced Files
F14146069: D12272.diff
Wed, Dec 4, 1:58 AM
Unknown Object (File)
Wed, Nov 27, 6:16 PM
Unknown Object (File)
Wed, Nov 20, 8:20 AM
Unknown Object (File)
Mon, Nov 18, 6:38 AM
Unknown Object (File)
Mon, Nov 18, 6:38 AM
Unknown Object (File)
Mon, Nov 18, 5:12 AM
Unknown Object (File)
Mon, Nov 18, 4:22 AM
Unknown Object (File)
Fri, Nov 15, 8:40 PM
Subscribers

Details

Summary

Use Cppcheck to lint XHPAST source files.

Test Plan

Ran arc lint --trace support/xhpast/xhpast.cpp and saw cppcheck invoked.

Diff Detail

Repository
rPHU libphutil
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

joshuaspence retitled this revision from to Use `cppcheck` to lint XHPAST source.
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)
joshuaspence added a reviewer: epriestley.

Here is the current output:

>>> Lint for support/xhpast/ast.hpp:


   Warning  (Cppcheck) uninitMemberVar
    Member variable 'yy_extra_type::insert_token' is not initialized in the
    constructor.

               9 
              10 class yy_extra_type {
              11   public:
    >>>       12     yy_extra_type() {
              13       lineno = 1;
              14       terminated = false;
              15       used = false;

   Warning  (Cppcheck) uninitMemberVar
    Member variable 'yy_extra_type::last_token' is not initialized in the
    constructor.

               9 
              10 class yy_extra_type {
              11   public:
    >>>       12     yy_extra_type() {
              13       lineno = 1;
              14       terminated = false;
              15       used = false;

   Warning  (Cppcheck) uninitMemberVar
    Member variable 'yy_extra_type::heredoc_yyleng' is not initialized in the
    constructor.

               9 
              10 class yy_extra_type {
              11   public:
    >>>       12     yy_extra_type() {
              13       lineno = 1;
              14       terminated = false;
              15       used = false;

   Warning  (Cppcheck) uninitMemberVar
    Member variable 'yy_extra_type::heredoc_data' is not initialized in the
    constructor.

               9 
              10 class yy_extra_type {
              11   public:
    >>>       12     yy_extra_type() {
              13       lineno = 1;
              14       terminated = false;
              15       used = false;

   Warning  (Cppcheck) uninitMemberVar
    Member variable 'yy_extra_type::used_attributes' is not initialized in
    the constructor.

               9 
              10 class yy_extra_type {
              11   public:
    >>>       12     yy_extra_type() {
              13       lineno = 1;
              14       terminated = false;
              15       used = false;

   Warning  (Cppcheck) uninitMemberVar
    Member variable 'yy_extra_type::old_expecting_xhp_class_statements' is
    not initialized in the constructor.

               9 
              10 class yy_extra_type {
              11   public:
    >>>       12     yy_extra_type() {
              13       lineno = 1;
              14       terminated = false;
              15       used = false;

   Warning  (Cppcheck) uninitMemberVar
    Member variable 'yy_extra_type::first_lineno' is not initialized in the
    constructor.

               9 
              10 class yy_extra_type {
              11   public:
    >>>       12     yy_extra_type() {
              13       lineno = 1;
              14       terminated = false;
              15       used = false;

   Warning  (Cppcheck) uninitMemberVar
    Member variable 'yy_extra_type::used_attributes' is not initialized in
    the constructor.

               9 
              10 class yy_extra_type {
              11   public:
    >>>       12     yy_extra_type() {
              13       lineno = 1;
              14       terminated = false;
              15       used = false;

   Warning  (Cppcheck) uninitMemberVar
    Member variable 'yy_extra_type::insert_token' is not initialized in the
    constructor.

               9 
              10 class yy_extra_type {
              11   public:
    >>>       12     yy_extra_type() {
              13       lineno = 1;
              14       terminated = false;
              15       used = false;

   Warning  (Cppcheck) uninitMemberVar
    Member variable 'yy_extra_type::last_token' is not initialized in the
    constructor.

               9 
              10 class yy_extra_type {
              11   public:
    >>>       12     yy_extra_type() {
              13       lineno = 1;
              14       terminated = false;
              15       used = false;

   Warning  (Cppcheck) uninitMemberVar
    Member variable 'yy_extra_type::heredoc_yyleng' is not initialized in the
    constructor.

               9 
              10 class yy_extra_type {
              11   public:
    >>>       12     yy_extra_type() {
              13       lineno = 1;
              14       terminated = false;
              15       used = false;

   Warning  (Cppcheck) uninitMemberVar
    Member variable 'yy_extra_type::heredoc_data' is not initialized in the
    constructor.

               9 
              10 class yy_extra_type {
              11   public:
    >>>       12     yy_extra_type() {
              13       lineno = 1;
              14       terminated = false;
              15       used = false;

   Warning  (Cppcheck) uninitMemberVar
    Member variable 'yy_extra_type::old_expecting_xhp_class_statements' is
    not initialized in the constructor.

               9 
              10 class yy_extra_type {
              11   public:
    >>>       12     yy_extra_type() {
              13       lineno = 1;
              14       terminated = false;
              15       used = false;

   Warning  (Cppcheck) uninitMemberVar
    Member variable 'yy_extra_type::first_lineno' is not initialized in the
    constructor.

               9 
              10 class yy_extra_type {
              11   public:
    >>>       12     yy_extra_type() {
              13       lineno = 1;
              14       terminated = false;
              15       used = false;
>>> Lint for support/xhpast/astnode.hpp:


   Warning  (Cppcheck) uninitMemberVar
    Member variable 'Token::lineno' is not initialized in the constructor.

              17       unsigned int lineno;
              18       unsigned int n;
              19 
    >>>       20       Token(unsigned int type, char *value, unsigned int n) :
              21         type(type),
              22         value(value),
              23         n(n) {

   Warning  (Cppcheck) uninitMemberVar
    Member variable 'Token::lineno' is not initialized in the constructor.

              17       unsigned int lineno;
              18       unsigned int n;
              19 
    >>>       20       Token(unsigned int type, char *value, unsigned int n) :
              21         type(type),
              22         value(value),
              23         n(n) {

   Warning  (Cppcheck) uninitMemberVar
    Member variable 'Token::lineno' is not initialized in the constructor.

              17       unsigned int lineno;
              18       unsigned int n;
              19 
    >>>       20       Token(unsigned int type, char *value, unsigned int n) :
              21         type(type),
              22         value(value),
              23         n(n) {

   Warning  (Cppcheck) uninitMemberVar
    Member variable 'Token::lineno' is not initialized in the constructor.

              17       unsigned int lineno;
              18       unsigned int n;
              19 
    >>>       20       Token(unsigned int type, char *value, unsigned int n) :
              21         type(type),
              22         value(value),
              23         n(n) {
>>> Lint for support/xhpast/xhpast.cpp:


   Warning  (Cppcheck) unusedVariable
    Unused variable: files

              12 void print_node(xhpast::Node *node);
              13 
              14 int main(int argc, char* argv[]) {
    >>>       15   vector<string> files;
              16 
              17   if (argc != 1) {
              18     //coupling: modify also libphutil/src/parser/xhpast/bin/PhutilXHPASTBinary.php

   Warning  (Cppcheck) variableScope
    The scope of the variable 'r' can be reduced.

              98 
              99 void print_node(xhpast::Node *node) {
             100   int l = -1;
    >>>      101   int r = -1;
             102   if (node->l_tok != -1) {
             103     l = node->l_tok;
             104   }

   Warning  (Cppcheck) invalidPrintfArgType_sint
    %d in format string (no. 1) requires 'int' but the argument type is
    'unsigned int'.

             104   }
             105 
             106   if (l == -1) {
    >>>      107     printf("[%d]", node->type);
             108   } else {
             109     if (node->r_tok != -1) {
             110       r = node->r_tok;

   Warning  (Cppcheck) invalidPrintfArgType_sint
    %d in format string (no. 1) requires 'int' but the argument type is
    'unsigned int'.

             110       r = node->r_tok;
             111     }
             112 
    >>>      113     printf("[%d, %d, %d", node->type, l, r);
             114     if (!node->children.empty()) {
             115       printf(", [");
             116       for (xhpast::node_list_t::iterator ii = node->children.begin();;) {
epriestley edited edge metadata.
This revision is now accepted and ready to land.Apr 4 2015, 11:58 AM
This revision was automatically updated to reflect the committed changes.