root rule checker

16
ROOT Rule Checker ROOT MEETING Jose Lo 22/04/2005

Upload: edita

Post on 04-Jan-2016

36 views

Category:

Documents


2 download

DESCRIPTION

ROOT MEETING Jose Lo 22/04/2005. ROOT Rule Checker. What is Rule Checker. A software developed by Software Engineering Research Group at ITC-Irst. A tool that verifies automatically the coding conventions. ROOT coding conventions based on Taligent Rules. How to run the Rule Checker. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: ROOT Rule Checker

ROOT Rule Checker

ROOT MEETING

Jose Lo22/04/2005

Page 2: ROOT Rule Checker

What is Rule Checker

● A software developed by Software Engineering Research Group at ITC-Irst.

● A tool that verifies automatically the coding conventions.

● ROOT coding conventions based on Taligent Rules

Page 3: ROOT Rule Checker

How to run the Rule Checker

● To check all files– make check-all

● To check one specific module (e.g. base)– make check-base

● Will create a sub-directory “check”● Violations files in *.viol

● To check one specific file– g++ -E -I... file.cxx > file.i– patch4alice.prl file.i– java rules.ROOT.RuleChecker file.i > file.viol

Page 4: ROOT Rule Checker

Rules

● RN 1 – Names should be chosen with care and should be meaningful.

● RN 2 – In names that consist of more than one word: – The words are written together.– The first letter of the name can be lower case or

capitalized (depends on the entity).– The first letters of the other words are always

capitalized.

Page 5: ROOT Rule Checker

Rules (cont.)

● RN 3 – Types begin with a capital letter and end with '_t'

● RN 4 – Base classes begin with 'T'● RN 6 – Enumeration types begin 'E'● RN 7 – Avoid Raw C types● RN 9 – Attributes begin with 'f' and functions

begin with a capital letter

Page 6: ROOT Rule Checker

Rules (cont.)

● RN 10 – Static variables begin with 'g'● RN 11 – Static data members begin with 'fg'● RN 12 – Local variables and parameters begin

with a lowercase word● RN 13 – Constants begin with 'k', including names

of enumeration, constants and constants statics

Page 7: ROOT Rule Checker

Table

Table

Page 8: ROOT Rule Checker

Example - RN3

RULE RN3 violated: @ Type begin with a capital letter and end with '_t' --> The Type: uuid_time_t in file TUUID.h does not start with a capital letter --------------------------------------------------

class TUUID {.... struct uuid_time_t { UInt_t high; UInt_t low; };

Page 9: ROOT Rule Checker

Example - RN4

@ Classes name begin with "T" --> the Class: RStl does not start with a 'T' --------------------------------------------------

class Rstl {

...

Page 10: ROOT Rule Checker

Example – RN 6

RULE RN6 violated: @ Enumeration types begin with"E" --> the enumerator: action [file: Match.cxx 40] does not start with "E" --------------------------------------------------

enum action { M_BOL = (0x8000 | '^'), M_EOL = (0x8000 | '$'), M_ANY = (0x8000 | '.'), .....

};

Page 11: ROOT Rule Checker

Example - RN7

RULE RN7 violated: @ Avoid using C raw types --> the member data: n in class: TSystem in method: ExpandFileName() [TSystem.cxx 857] is a raw C type: int --------------------------------------------------const char *TSystem::ExpandFileName(const char *fname){ .... int n, ier, iter, lx, ncopy;

Page 12: ROOT Rule Checker

Example – RN 9

RULE RN9 violated: @ Member function names start with a capital --> the method: cd(const char *): Bool_t in class: TDirectory does not start with a capital

--------------------------------------------------Bool_t TDirectory::cd(const char *path){...}

Page 13: ROOT Rule Checker

Example – RN 10

RULE RN10 violated: @ Static variables start with a prefix "g"@ applies to static variables in functions and global variables --> the static data member: framewasdrawn in class: null does not start with a prefix "g" --------------------------------------------------void TView::ExecuteRotateView(Int_t event, Int_t px, Int_t py){

static Int_t system, framewasdrawn;...

Page 14: ROOT Rule Checker

Example – RN 11

RULE RN11 violated: @ Static data member names start with a prefix "fg" --> the static data member: s_objectTable in class: MemoryRegulator does not start with a prefix "fg" --------------------------------------------------

class MemoryRegulator : public TObject { .... static objmap_t s_objectTable;

Page 15: ROOT Rule Checker

Example – RN 12

RULE RN12 violated: @ Local variables names start with a lower case letter --> the variable: X [file: TMath.cxx 987] in function: Voigt(Double_t, Double_t, Double_t, Int_t): Double_t does not start with a lower case letter --------------------------------------------------

Double_t TMath::Voigt(Double_t x, Double_t sigma, Double_t lg, Int_t R){ .... Double_t X, Y, K;

Page 16: ROOT Rule Checker

Example – RN 13

RULE RN13 violated: @ Constant, including names in enumeration types@ and constant static start with a prefix "k" --> the constant: p1 [TMath.cxx 3237] does not start with a prefix "k" --------------------------------------------------

Double_t TMath::BesselI1(Double_t x){ .... const Double_t p1=0.5, p2=0.87890594, p3=0.51498869,