Page MenuHomePhabricator

Use `cppcheck` to lint XHPAST source
ClosedPublic

Authored by joshuaspence on Apr 4 2015, 5:17 AM.
Tags
None
Referenced Files
F13134953: D12272.diff
Thu, May 2, 6:06 AM
Unknown Object (File)
Wed, May 1, 10:58 AM
Unknown Object (File)
Sat, Apr 27, 11:47 AM
Unknown Object (File)
Fri, Apr 26, 4:43 AM
Unknown Object (File)
Fri, Apr 26, 4:42 AM
Unknown Object (File)
Fri, Apr 26, 4:42 AM
Unknown Object (File)
Tue, Apr 23, 3:49 PM
Unknown Object (File)
Sat, Apr 20, 5:31 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.