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

Introduce npm run lint command for cpp formatting #752

Closed
wants to merge 1 commit into from

Conversation

simonhong
Copy link
Member

@simonhong simonhong commented Aug 15, 2018

This command automatically formats a pending patch of brave core according to Chromium style.
See documents about git cl format : https://chromium.googlesource.com/chromium/src/+/lkcr/docs/clang_format.md

close #116

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Verified that these changes build without errors on
    • Windows
    • macOS
    • Linux
  • Verified that these changes pass automated tests (npm test brave_unit_tests && npm test brave_browser_tests) on
    • Windows
    • macOS
    • Linux
  • Ran git rebase master (if needed).
  • Ran git rebase -i to squash commits (if needed).
  • Tagged reviewers and labelled the pull request as needed.
  • Requested a security/privacy review as needed.

Test Plan:

run yarn lint after making changes in brave-core.

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions.

@simonhong simonhong self-assigned this Aug 15, 2018
Copy link
Member

@bbondy bbondy left a comment

Choose a reason for hiding this comment

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

I think you might have forgotten to add lib/lint.js

@@ -17,6 +17,7 @@ const chromiumRebaseL10n = require('../lib/chromiumRebaseL10n')
const createDist = require('../lib/createDist')
const upload = require('../lib/upload')
const test = require('../lib/test')
const lint = require('../lib/lint')
Copy link
Member

Choose a reason for hiding this comment

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

I think maybe you moved it to util but this is still around and it should get it from util instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

did you forget to add lint.js?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops. I forgot to add lint.js. Added.

console.log('linting ' + config.projects['brave-core'].dir + '...')
options.cwd = config.projects['brave-core'].dir
options = mergeWithDefault(options)
// git cl format checks rietveld.server is set. Just set null.
Copy link
Contributor

Choose a reason for hiding this comment

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

what is rietveld.server?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it is code review site of chromium project.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused about what git cl has to do with lint. We want to call vendor/depot_tools/cpplint.py in some kind of push hook

Copy link
Member Author

@simonhong simonhong Aug 16, 2018

Choose a reason for hiding this comment

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

I didn't read full git_cl.py, but it seems it uses cpplint.py for lint internally. it seems it utilizes clang_format.py.
How about providing two kinds of formatting ways - npm run lint and git hook?

Copy link
Member Author

Choose a reason for hiding this comment

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

git cl is utilities for chromium code review - https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/git-cl.html
It has many subcommands and we can easily use format or lint subcommand for our formatting

Copy link
Contributor

Choose a reason for hiding this comment

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

but there's no changelist to run it on. We need it to run on directory. I just tried to run and got Cannot lint an empty CL
we also need to make sure we're using cpplint.py in all cases

Copy link
Member Author

Choose a reason for hiding this comment

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

Did you have any modification in src/brave?
That command tries to reformat files that has changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

lint should fail right now whether there are changes or not because I've seen dozens of what would be lint errors in the code

Copy link
Member Author

Choose a reason for hiding this comment

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

If you use format it will detect the errors.
As I told you in DM, if we want to use cpplint.py instead of clang_format, git cl would not be the good choice.

This command automatically formats a pending patch according to
Chromium style.
@simonhong
Copy link
Member Author

Will reopen again when ready.

@simonhong simonhong closed this Aug 20, 2018
@mihaiplesa mihaiplesa deleted the introduce_npm_lint branch May 10, 2019 21:33
@mihaiplesa mihaiplesa restored the introduce_npm_lint branch May 10, 2019 21:33
@simonhong simonhong deleted the introduce_npm_lint branch June 12, 2019 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create an npm run lint script for cpp linting
3 participants