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

Add Linter #103

Merged
merged 6 commits into from
May 25, 2021
Merged

Add Linter #103

merged 6 commits into from
May 25, 2021

Conversation

sdiao
Copy link
Contributor

@sdiao sdiao commented May 20, 2021

Proposed change(s)

  • Add dotnet format linter
  • Add pre-commit hook to reformat code automatically
  • Format files

Useful links (GitHub issues, JIRA tickets, forum threads, etc.)

Inspired by:
https://github.com/dotnet/format
ML-Agents linter setup: Unity-Technologies/ml-agents#4362

Following the tutorial in https://pre-commit.com/ to set up pre-commit locally.
Run pip install pre-commit-hooks to set up the pre-commit-hooks.
To run a specific hook, you can use pre-commit run mixed-line-ending --all-files
To run the pre-commit check, make some format change locally, e.g. adding trailing whitespace, extra line, extra space. Next run git add <file to be staged>, and git commit -m <msg>, you should see the format will be automatically fixed.

Types of change(s)

  • Bug fix
  • New feature
  • Code refactor - formatting
  • Documentation update
  • Other (please describe) - add linter to the repo

Testing and Verification

Please describe the tests that you ran to verify your changes. Please also provide instructions, ROS packages, and Unity project files as appropriate so we can reproduce the test environment.

Test Configuration:

  • Unity Version: [e.g. Unity 2020.2.0f1]
  • Unity machine OS + version: [e.g. Windows 10]
  • ROS machine OS + version: [e.g. Ubuntu 18.04, ROS Noetic]
  • ROS–Unity communication: [e.g. Docker]

Checklist

  • Ensured this PR is up-to-date with the dev branch
  • Created this PR to target the dev branch
  • Followed the style guidelines as described in the Contribution Guidelines
  • Added tests that prove my fix is effective or that my feature works
  • Updated the documentation as appropriate

Other comments

@@ -0,0 +1,75 @@
; see http://editorconfig.org/ for docs on this file
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Inspired by ML-Agents repo's config. We are using dotnet format to format C# code.

@@ -0,0 +1,31 @@
repos:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Key pre-commit config setup.

@@ -3,14 +3,14 @@
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

## Installation
1. Using Unity 2020.2 or later, open the package manager from `Window` -> `Package Manager` and select "Add package from git URL..."
Copy link
Contributor Author

Choose a reason for hiding this comment

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

markdown files format are fixed automatically. Instruction to set up: https://pre-commit.com/
To try it out locally, run pre-commit run --files *.md
Screen Shot 2021-05-20 at 5 15 37 PM

- uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
- uses: pre-commit/[email protected]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Inspired by ML-Agents team's config. We are adding a Github Check here, so that once a pull request is opened, Github will run the pre-commit check as well.

Success check example
Failed check example

@sdiao sdiao changed the title WIP: Add Linter Add Linter May 21, 2021
@sdiao sdiao requested a review from peifeng-unity May 21, 2021 17:17
.editorconfig Show resolved Hide resolved
ROSGeometry.md Show resolved Hide resolved
Comment on lines +29 to +33
msg.linear_acceleration = acceleration.To<FLU>();
msg.orientation = rigidbody.transform.rotation.To<FLU>();
msg.angular_velocity = rigidbody.angularVelocity.To<FLU>();
ros.Send("imu", msg);
Copy link
Contributor

Choose a reason for hiding this comment

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

use var and a more descriptive name than msg (note: msg abbreviation is ok)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would it be good to keep this PR only adding the linter and formatting? Happy to open a separate PR to update the sample code in markdown files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks we already have a task AIRO-667 to update the doc. Doc changes will be made in a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok when I expand the code I can see that this "addition" is really just moving it around. Our current rule is that if the code is new, or if you are re-writing older code for some reason, it must be changed to follow the coding standards if it doesn't already. Since this is technically a change and not a move, it's ok to defer.

ROSGeometry.md Show resolved Hide resolved
ROSGeometry.md Show resolved Hide resolved
@sdiao sdiao requested a review from mrpropellers May 24, 2021 22:40
Copy link
Contributor

@peifeng-unity peifeng-unity left a comment

Choose a reason for hiding this comment

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

LGTM

@sdiao sdiao merged commit a8d7f53 into dev May 25, 2021
sdiao added a commit that referenced this pull request Jun 1, 2021
* Add ROS# link (#55)

* Add ROS# link

* Fixing message name that should not take a capital first letter automatically (#47)

* Fixing message name that should not take a capital first letter automatically
* Adding warning when a message file name starts with a lowercase character

* AIRO-331 Code Cleanup and Testing Framework (#57)

* Moving package files into package subdirectory

* Adding tests and fixing Yamato config.

* Adding missing using statement to MessageParser

* RosMessageGeneration namespace change (#61)

* Amanda/read chunks (#62)

* Read message in chunks min

* Removing unpredictable DataAvailable check

* Configurable byte chun
k size

* Prevent infinite hang on reading message contents

* Wait for frame on data read retry

* PR Feedback

* Adding prebuilt ObjectRecognition and Octomap messages (#64)

* M prefix for all messages (#66)

* Topic list service (#72)

* Adding install instructions to README

Partially addressing issue #71 wherein a user couldn't find up-to-date instructions for installing the connector into a new project.

* Updating Contribution Content (#77)

* Contributing content commit

* Link fix

* PR feedback

* Adding PR template (#81)

* One persistent connection for all messages sent to Unity

* Read multiple messages from each connection

* Compiles

* First thing sent on each new connection is the timeout

* Comments!

* Stop the connection on leaving play mode

* Add a "timeout on idle" config setting so Endpoint doesn't have to send it

* IP address check for Unity IP address and ROS IP address  (#80)

* Add Ip address check

* Adding condition for alphaumeric IP address

https://man7.org/linux/man-pages/man5/hosts.5.html

* Resolve conflicts

Resolve the conflicts to merge dev to main

* Update package.json (#87)

* Update version number in readme, and clean up some weird instructions (#89)

* MDuration namespace change (#91)

* Minor link fix (#98)

* RosConnection 2.0 (#94)

* add changelog (#100)

add changelog

* Forum links to README, config.yml (#101)

* Laurie/connection status hud (#99)

* add test coverage (#102)

* Reducing character count for path to generated messages

The path from the package root to the root of the PregeneratedMessages
folder was 47 characters. From within the PickAndPlace project, the
fully qualified path including drive letter, path to workspace, and path
to its location in the package cache can easily exceed 200 characters,
especially for users with long names or deep workspace organization.
The maximum allowed path length for a fully qualified path in Windows is
260 characters, after which an IDE can not compile the assemblies for
source with too-long paths.

Moved Runtime/MessageGeneration/PregeneratedMessages to
Runtime/Messages, which saves 30 characters off the full path name. This
is a mitigation that can not fully solve the problem, but wil at least
reduce the number of cases for which the ROS-TCP-Endpoint assemblies
fail to compile due to path length.

Tested on my machine by manually renaming the directory in my
PackageCache.

* Add Linter (#103)

* Add editorconfig for formatting

* Use linter to format the package code

* Add pre-commit hook

* Fix line endings for markdown

Fix trailing-whitespace

* Remove ruby setup; Change to run pre-commit only on pull-requests

* Resolve conflicts (#106)

* Shuo/resolve conflict (#107)

* Merge 0.3.0 to main (#90)

* Add ROS# link (#55)

* Add ROS# link

* Fixing message name that should not take a capital first letter automatically (#47)

* Fixing message name that should not take a capital first letter automatically
* Adding warning when a message file name starts with a lowercase character

* AIRO-331 Code Cleanup and Testing Framework (#57)

* Moving package files into package subdirectory

* Adding tests and fixing Yamato config.

* Adding missing using statement to MessageParser

* RosMessageGeneration namespace change (#61)

* Amanda/read chunks (#62)

* Read message in chunks min

* Removing unpredictable DataAvailable check

* Configurable byte chun
k size

* Prevent infinite hang on reading message contents

* Wait for frame on data read retry

* PR Feedback

* Adding prebuilt ObjectRecognition and Octomap messages (#64)

* M prefix for all messages (#66)

* Topic list service (#72)

* Adding install instructions to README

Partially addressing issue #71 wherein a user couldn't find up-to-date instructions for installing the connector into a new project.

* Updating Contribution Content (#77)

* Contributing content commit

* Link fix

* PR feedback

* Adding PR template (#81)

* One persistent connection for all messages sent to Unity

* Read multiple messages from each connection

* Compiles

* First thing sent on each new connection is the timeout

* Comments!

* Stop the connection on leaving play mode

* Add a "timeout on idle" config setting so Endpoint doesn't have to send it

* IP address check for Unity IP address and ROS IP address  (#80)

* Add Ip address check

* Adding condition for alphaumeric IP address

https://man7.org/linux/man-pages/man5/hosts.5.html

* Resolve conflicts

Resolve the conflicts to merge dev to main

* Update package.json (#87)

* Update version number in readme, and clean up some weird instructions (#89)

Co-authored-by: Devin Miller (Unity) <[email protected]>
Co-authored-by: Amanda <[email protected]>
Co-authored-by: vidurvij-Unity <[email protected]>
Co-authored-by: peifeng-unity <[email protected]>

* Remove deprecated files

Co-authored-by: LaurieCheers-unity <[email protected]>
Co-authored-by: Devin Miller (Unity) <[email protected]>
Co-authored-by: Amanda <[email protected]>
Co-authored-by: vidurvij-Unity <[email protected]>
Co-authored-by: peifeng-unity <[email protected]>

* add changelog meta file (#109)

* update version to 0.4.0 (#110)

* rremove stale merge

Co-authored-by: Devin Miller (Unity) <[email protected]>
Co-authored-by: LaurieCheers-unity <[email protected]>
Co-authored-by: Amanda <[email protected]>
Co-authored-by: vidurvij-Unity <[email protected]>
Co-authored-by: peifeng-unity <[email protected]>
Co-authored-by: Devin Miller (Unity) <[email protected]>
Co-authored-by: peifeng-unity <[email protected]>
sdiao added a commit that referenced this pull request Jun 1, 2021
* Add ROS# link (#55)

* Add ROS# link

* Fixing message name that should not take a capital first letter automatically (#47)

* Fixing message name that should not take a capital first letter automatically
* Adding warning when a message file name starts with a lowercase character

* AIRO-331 Code Cleanup and Testing Framework (#57)

* Moving package files into package subdirectory

* Adding tests and fixing Yamato config.

* Adding missing using statement to MessageParser

* RosMessageGeneration namespace change (#61)

* Amanda/read chunks (#62)

* Read message in chunks min

* Removing unpredictable DataAvailable check

* Configurable byte chun
k size

* Prevent infinite hang on reading message contents

* Wait for frame on data read retry

* PR Feedback

* Adding prebuilt ObjectRecognition and Octomap messages (#64)

* M prefix for all messages (#66)

* Topic list service (#72)

* Adding install instructions to README

Partially addressing issue #71 wherein a user couldn't find up-to-date instructions for installing the connector into a new project.

* Updating Contribution Content (#77)

* Contributing content commit

* Link fix

* PR feedback

* Adding PR template (#81)

* One persistent connection for all messages sent to Unity

* Read multiple messages from each connection

* Compiles

* First thing sent on each new connection is the timeout

* Comments!

* Stop the connection on leaving play mode

* Add a "timeout on idle" config setting so Endpoint doesn't have to send it

* IP address check for Unity IP address and ROS IP address  (#80)

* Add Ip address check

* Adding condition for alphaumeric IP address

https://man7.org/linux/man-pages/man5/hosts.5.html

* Resolve conflicts

Resolve the conflicts to merge dev to main

* Update package.json (#87)

* Update version number in readme, and clean up some weird instructions (#89)

* MDuration namespace change (#91)

* Minor link fix (#98)

* RosConnection 2.0 (#94)

* add changelog (#100)

add changelog

* Forum links to README, config.yml (#101)

* Laurie/connection status hud (#99)

* add test coverage (#102)

* Reducing character count for path to generated messages

The path from the package root to the root of the PregeneratedMessages
folder was 47 characters. From within the PickAndPlace project, the
fully qualified path including drive letter, path to workspace, and path
to its location in the package cache can easily exceed 200 characters,
especially for users with long names or deep workspace organization.
The maximum allowed path length for a fully qualified path in Windows is
260 characters, after which an IDE can not compile the assemblies for
source with too-long paths.

Moved Runtime/MessageGeneration/PregeneratedMessages to
Runtime/Messages, which saves 30 characters off the full path name. This
is a mitigation that can not fully solve the problem, but wil at least
reduce the number of cases for which the ROS-TCP-Endpoint assemblies
fail to compile due to path length.

Tested on my machine by manually renaming the directory in my
PackageCache.

* Add Linter (#103)

* Add editorconfig for formatting

* Use linter to format the package code

* Add pre-commit hook

* Fix line endings for markdown

Fix trailing-whitespace

* Remove ruby setup; Change to run pre-commit only on pull-requests

* Resolve conflicts (#106)

* Shuo/resolve conflict (#107)

* Merge 0.3.0 to main (#90)

* Add ROS# link (#55)

* Add ROS# link

* Fixing message name that should not take a capital first letter automatically (#47)

* Fixing message name that should not take a capital first letter automatically
* Adding warning when a message file name starts with a lowercase character

* AIRO-331 Code Cleanup and Testing Framework (#57)

* Moving package files into package subdirectory

* Adding tests and fixing Yamato config.

* Adding missing using statement to MessageParser

* RosMessageGeneration namespace change (#61)

* Amanda/read chunks (#62)

* Read message in chunks min

* Removing unpredictable DataAvailable check

* Configurable byte chun
k size

* Prevent infinite hang on reading message contents

* Wait for frame on data read retry

* PR Feedback

* Adding prebuilt ObjectRecognition and Octomap messages (#64)

* M prefix for all messages (#66)

* Topic list service (#72)

* Adding install instructions to README

Partially addressing issue #71 wherein a user couldn't find up-to-date instructions for installing the connector into a new project.

* Updating Contribution Content (#77)

* Contributing content commit

* Link fix

* PR feedback

* Adding PR template (#81)

* One persistent connection for all messages sent to Unity

* Read multiple messages from each connection

* Compiles

* First thing sent on each new connection is the timeout

* Comments!

* Stop the connection on leaving play mode

* Add a "timeout on idle" config setting so Endpoint doesn't have to send it

* IP address check for Unity IP address and ROS IP address  (#80)

* Add Ip address check

* Adding condition for alphaumeric IP address

https://man7.org/linux/man-pages/man5/hosts.5.html

* Resolve conflicts

Resolve the conflicts to merge dev to main

* Update package.json (#87)

* Update version number in readme, and clean up some weird instructions (#89)

Co-authored-by: Devin Miller (Unity) <[email protected]>
Co-authored-by: Amanda <[email protected]>
Co-authored-by: vidurvij-Unity <[email protected]>
Co-authored-by: peifeng-unity <[email protected]>

* Remove deprecated files

Co-authored-by: LaurieCheers-unity <[email protected]>
Co-authored-by: Devin Miller (Unity) <[email protected]>
Co-authored-by: Amanda <[email protected]>
Co-authored-by: vidurvij-Unity <[email protected]>
Co-authored-by: peifeng-unity <[email protected]>

* add changelog meta file (#109)

* update version to 0.4.0 (#110)

* rremove stale merge

Co-authored-by: Devin Miller (Unity) <[email protected]>
Co-authored-by: LaurieCheers-unity <[email protected]>
Co-authored-by: Amanda <[email protected]>
Co-authored-by: vidurvij-Unity <[email protected]>
Co-authored-by: peifeng-unity <[email protected]>
Co-authored-by: Devin Miller (Unity) <[email protected]>
Co-authored-by: peifeng-unity <[email protected]>

Co-authored-by: Devin Miller (Unity) <[email protected]>
Co-authored-by: LaurieCheers-unity <[email protected]>
Co-authored-by: Amanda <[email protected]>
Co-authored-by: vidurvij-Unity <[email protected]>
Co-authored-by: peifeng-unity <[email protected]>
Co-authored-by: Devin Miller (Unity) <[email protected]>
Co-authored-by: peifeng-unity <[email protected]>
P3TE pushed a commit to P3TE/ROS-TCP-Connector that referenced this pull request Jul 13, 2021
* Add ROS# link (Unity-Technologies#55)

* Add ROS# link

* Fixing message name that should not take a capital first letter automatically (Unity-Technologies#47)

* Fixing message name that should not take a capital first letter automatically
* Adding warning when a message file name starts with a lowercase character

* AIRO-331 Code Cleanup and Testing Framework (Unity-Technologies#57)

* Moving package files into package subdirectory

* Adding tests and fixing Yamato config.

* Adding missing using statement to MessageParser

* RosMessageGeneration namespace change (Unity-Technologies#61)

* Amanda/read chunks (Unity-Technologies#62)

* Read message in chunks min

* Removing unpredictable DataAvailable check

* Configurable byte chun
k size

* Prevent infinite hang on reading message contents

* Wait for frame on data read retry

* PR Feedback

* Adding prebuilt ObjectRecognition and Octomap messages (Unity-Technologies#64)

* M prefix for all messages (Unity-Technologies#66)

* Topic list service (Unity-Technologies#72)

* Adding install instructions to README

Partially addressing issue Unity-Technologies#71 wherein a user couldn't find up-to-date instructions for installing the connector into a new project.

* Updating Contribution Content (Unity-Technologies#77)

* Contributing content commit

* Link fix

* PR feedback

* Adding PR template (Unity-Technologies#81)

* One persistent connection for all messages sent to Unity

* Read multiple messages from each connection

* Compiles

* First thing sent on each new connection is the timeout

* Comments!

* Stop the connection on leaving play mode

* Add a "timeout on idle" config setting so Endpoint doesn't have to send it

* IP address check for Unity IP address and ROS IP address  (Unity-Technologies#80)

* Add Ip address check

* Adding condition for alphaumeric IP address

https://man7.org/linux/man-pages/man5/hosts.5.html

* Resolve conflicts

Resolve the conflicts to merge dev to main

* Update package.json (Unity-Technologies#87)

* Update version number in readme, and clean up some weird instructions (Unity-Technologies#89)

* MDuration namespace change (Unity-Technologies#91)

* Minor link fix (Unity-Technologies#98)

* RosConnection 2.0 (Unity-Technologies#94)

* add changelog (Unity-Technologies#100)

add changelog

* Forum links to README, config.yml (Unity-Technologies#101)

* Laurie/connection status hud (Unity-Technologies#99)

* add test coverage (Unity-Technologies#102)

* Reducing character count for path to generated messages

The path from the package root to the root of the PregeneratedMessages
folder was 47 characters. From within the PickAndPlace project, the
fully qualified path including drive letter, path to workspace, and path
to its location in the package cache can easily exceed 200 characters,
especially for users with long names or deep workspace organization.
The maximum allowed path length for a fully qualified path in Windows is
260 characters, after which an IDE can not compile the assemblies for
source with too-long paths.

Moved Runtime/MessageGeneration/PregeneratedMessages to
Runtime/Messages, which saves 30 characters off the full path name. This
is a mitigation that can not fully solve the problem, but wil at least
reduce the number of cases for which the ROS-TCP-Endpoint assemblies
fail to compile due to path length.

Tested on my machine by manually renaming the directory in my
PackageCache.

* Add Linter (Unity-Technologies#103)

* Add editorconfig for formatting

* Use linter to format the package code

* Add pre-commit hook

* Fix line endings for markdown

Fix trailing-whitespace

* Remove ruby setup; Change to run pre-commit only on pull-requests

* Resolve conflicts (Unity-Technologies#106)

* Shuo/resolve conflict (Unity-Technologies#107)

* Merge 0.3.0 to main (Unity-Technologies#90)

* Add ROS# link (Unity-Technologies#55)

* Add ROS# link

* Fixing message name that should not take a capital first letter automatically (Unity-Technologies#47)

* Fixing message name that should not take a capital first letter automatically
* Adding warning when a message file name starts with a lowercase character

* AIRO-331 Code Cleanup and Testing Framework (Unity-Technologies#57)

* Moving package files into package subdirectory

* Adding tests and fixing Yamato config.

* Adding missing using statement to MessageParser

* RosMessageGeneration namespace change (Unity-Technologies#61)

* Amanda/read chunks (Unity-Technologies#62)

* Read message in chunks min

* Removing unpredictable DataAvailable check

* Configurable byte chun
k size

* Prevent infinite hang on reading message contents

* Wait for frame on data read retry

* PR Feedback

* Adding prebuilt ObjectRecognition and Octomap messages (Unity-Technologies#64)

* M prefix for all messages (Unity-Technologies#66)

* Topic list service (Unity-Technologies#72)

* Adding install instructions to README

Partially addressing issue Unity-Technologies#71 wherein a user couldn't find up-to-date instructions for installing the connector into a new project.

* Updating Contribution Content (Unity-Technologies#77)

* Contributing content commit

* Link fix

* PR feedback

* Adding PR template (Unity-Technologies#81)

* One persistent connection for all messages sent to Unity

* Read multiple messages from each connection

* Compiles

* First thing sent on each new connection is the timeout

* Comments!

* Stop the connection on leaving play mode

* Add a "timeout on idle" config setting so Endpoint doesn't have to send it

* IP address check for Unity IP address and ROS IP address  (Unity-Technologies#80)

* Add Ip address check

* Adding condition for alphaumeric IP address

https://man7.org/linux/man-pages/man5/hosts.5.html

* Resolve conflicts

Resolve the conflicts to merge dev to main

* Update package.json (Unity-Technologies#87)

* Update version number in readme, and clean up some weird instructions (Unity-Technologies#89)

Co-authored-by: Devin Miller (Unity) <[email protected]>
Co-authored-by: Amanda <[email protected]>
Co-authored-by: vidurvij-Unity <[email protected]>
Co-authored-by: peifeng-unity <[email protected]>

* Remove deprecated files

Co-authored-by: LaurieCheers-unity <[email protected]>
Co-authored-by: Devin Miller (Unity) <[email protected]>
Co-authored-by: Amanda <[email protected]>
Co-authored-by: vidurvij-Unity <[email protected]>
Co-authored-by: peifeng-unity <[email protected]>

* add changelog meta file (Unity-Technologies#109)

* update version to 0.4.0 (Unity-Technologies#110)

* rremove stale merge

Co-authored-by: Devin Miller (Unity) <[email protected]>
Co-authored-by: LaurieCheers-unity <[email protected]>
Co-authored-by: Amanda <[email protected]>
Co-authored-by: vidurvij-Unity <[email protected]>
Co-authored-by: peifeng-unity <[email protected]>
Co-authored-by: Devin Miller (Unity) <[email protected]>
Co-authored-by: peifeng-unity <[email protected]>
peifeng-unity pushed a commit that referenced this pull request Jul 15, 2021
* Add editorconfig for formatting

* Use linter to format the package code

* Add pre-commit hook

* Fix line endings for markdown

Fix trailing-whitespace

* Remove ruby setup; Change to run pre-commit only on pull-requests
peifeng-unity pushed a commit that referenced this pull request Jul 15, 2021
* Add editorconfig for formatting

* Use linter to format the package code

* Add pre-commit hook

* Fix line endings for markdown

Fix trailing-whitespace

* Remove ruby setup; Change to run pre-commit only on pull-requests
@sdiao sdiao deleted the shuo/add-linter branch July 30, 2021 21:39
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.

4 participants