Skip to content
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

clang check Alignment #22259

Conversation

davidlange6
Copy link
Contributor

Changes in Alignment subsystem due to clang-tidy if #21478 is merged

@cmsbuild
Copy link
Contributor

The code-checks are being triggered in jenkins.

@cmsbuild
Copy link
Contributor

-code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-22259/3432

Code check has found code style and quality issues which could be resolved by applying a patch in https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-22259/3432/git-diff.patch
e.g. curl https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-22259/3432/git-diff.patch | patch -p1

You can run scram build code-checks to apply code checks directly

@davidlange6
Copy link
Contributor Author

hum, those code checks seem unlikely to compile - the clang-changes must have caused problems elsewhere (that I didn't check for)

@davidlange6
Copy link
Contributor Author

here is an example of the bug introduced

if (newBareTkGeomPtr == bareTkGeomPtr_) { return; // already booked hists, nothing changed }

end-of-line comments are not dealt with correctly.

@@ -417,7 +417,7 @@ TrackerOfflineValidation::checkBookHists(const edm::EventSetup& es)
{
es.get<TrackerDigiGeometryRecord>().get( tkGeom_ );
const TrackerGeometry *newBareTkGeomPtr = &(*tkGeom_);
if (newBareTkGeomPtr == bareTkGeomPtr_) return; // already booked hists, nothing changed
if (newBareTkGeomPtr == bareTkGeomPtr_) { return; // already booked hists, nothing changed }
Copy link
Contributor

Choose a reason for hiding this comment

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

I've tried to reproduce this wrong substitution with a minimal test case, and I haven't been able to.
What options did you use ?

Copy link
Contributor

Choose a reason for hiding this comment

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

@davidlange6 and @fwyzard this was due to cmssw build rules. We run clang-tidy with -export-fixes option and then post process the generated yaml files to

  • drop suggested change for files which are not part of PR change set
  • remove duplicate changes for headers files

Problem is that when we write back the yaml file (using pyYAML) then it drops the extra new line e.g. if originally we have

Diagnostics:     
  - DiagnosticName:  readability-braces-around-statements
    Message:         statement should be inside braces
    FileOffset:      566
    FilePath:        /build/muz/cf/CMSSW_10_6_X_2019-04-11-2300/src/Alignment/CocoaModel/interface/MeasurementCOPS.h
    Replacements:    
      - FilePath:        /build/muz/cf/CMSSW_10_6_X_2019-04-11-2300/src/Alignment/CocoaModel/interface/MeasurementCOPS.h
        Offset:          566
        Length:          0
        ReplacementText: ' {'
      - FilePath:        /build/muz/cf/CMSSW_10_6_X_2019-04-11-2300/src/Alignment/CocoaModel/interface/MeasurementCOPS.h
        Offset:          591
        Length:          0
        ReplacementText: '
}'

then reading it and writing back generates

Diagnostics:     
  - DiagnosticName:  readability-braces-around-statements
    Message:         statement should be inside braces
    FileOffset:      566
    FilePath:        /build/muz/cf/CMSSW_10_6_X_2019-04-11-2300/src/Alignment/CocoaModel/interface/MeasurementCOPS.h
    Replacements:    
      - FilePath:        /build/muz/cf/CMSSW_10_6_X_2019-04-11-2300/src/Alignment/CocoaModel/interface/MeasurementCOPS.h
        Offset:          566
        Length:          0
        ReplacementText: ' {'
      - FilePath:        /build/muz/cf/CMSSW_10_6_X_2019-04-11-2300/src/Alignment/CocoaModel/interface/MeasurementCOPS.h
        Offset:          591
        Length:          0
        ReplacementText: ' }'

this causes the closing braces to be on the same line. This should be fixes once we have cms-sw/cmsdist#4914 merged.

@davidlange6
Copy link
Contributor Author

davidlange6 commented Feb 20, 2018 via email

@fwyzard
Copy link
Contributor

fwyzard commented Feb 20, 2018

Mhm, strange.

I just ran

clang-tidy --fix Alignment/OfflineValidation/plugins/TrackerOfflineValidation.cc

and I got a valid file:

@@ -417,7 +424,8 @@ TrackerOfflineValidation::checkBookHists(const edm::EventSetup& es)
 {
   es.get<TrackerDigiGeometryRecord>().get( tkGeom_ );
   const TrackerGeometry *newBareTkGeomPtr = &(*tkGeom_);
-  if (newBareTkGeomPtr == bareTkGeomPtr_) return; // already booked hists, nothing changed
+  if (newBareTkGeomPtr == bareTkGeomPtr_) { return; // already booked hists, nothing changed
+}
 
   if (!bareTkGeomPtr_) { // pointer not yet set: called the first time => book hists
 

@davidlange6
Copy link
Contributor Author

davidlange6 commented Feb 20, 2018 via email

@davidlange6
Copy link
Contributor Author

Your PR is unmergeable. Please have a look and possibly rebase it.

@smuzaffar smuzaffar modified the milestones: CMSSW_10_1_X, CMSSW_10_2_X Mar 29, 2018
@arunhep
Copy link
Contributor

arunhep commented Apr 16, 2018

@davidlange6 would you like to continue with these changes? Or if not, then may be you want to close it.
thanks.

@arunhep
Copy link
Contributor

arunhep commented May 8, 2018

ping

@arunhep
Copy link
Contributor

arunhep commented May 15, 2018

-1
to remove it from the list

@smuzaffar smuzaffar modified the milestones: CMSSW_10_2_X, CMSSW_10_3_X Jul 17, 2018
@smuzaffar smuzaffar removed this from the CMSSW_10_3_X milestone Oct 10, 2018
@smuzaffar smuzaffar added this to the CMSSW_10_4_X milestone Oct 10, 2018
@smuzaffar smuzaffar modified the milestones: CMSSW_10_4_X, CMSSW_10_5_X Dec 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants