Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Use of hard tabs in code style ? #9173

Closed
breadoven opened this issue Jul 12, 2023 · 7 comments
Closed

Use of hard tabs in code style ? #9173

breadoven opened this issue Jul 12, 2023 · 7 comments

Comments

@breadoven
Copy link
Collaborator

I've noticed there seems to be a lot of hard tabs used in PR's that have been merged recently. This screws up the formatting of the code when viewed on Github making it hard to read. I thought hard tabs were not to be used according to:

https://github.com/multiwii/baseflight/wiki/CodingStyle

Has this requirement been relaxed ?

@MrD-RC
Copy link
Collaborator

MrD-RC commented Jul 12, 2023

Not as far as I know. Tabs should be used for indentation, not spaces.

@breadoven
Copy link
Collaborator Author

You can use Tabs, just not hard tabs, soft Tabs should be used, i.e. padded with spaces. Your code editor should be set up to make a Tab 4 spaces, a soft tab. If you don't do this then the file viewer will tabulate the code according to its tabulation settings which may not correspond to 4 spaces. Using a soft Tab ensures consistency because a space should be consistent across viewers.

The affect of hard tabs can be seen here with the indentation a mess:
Screenshot (155)
The arrows are hard Tabs:
Screenshot (156)

It should look like this to avoid this problem, i.e. just spaces:
Screenshot (158)

I seem to remember the Workflow checker used to fail if hard tabs were used. Obviously this doesn't happen any more.

@MrD-RC
Copy link
Collaborator

MrD-RC commented Jul 15, 2023

Damn, just realised I'm a perp here! VSCode uses hard tabs by default. I've just changed the setting. In the settings, search for Insert spaces. It will return Editor: Insert Spaces Turn that off, and it stops with the hard spaces.

@stronnag
Copy link
Collaborator

Unfortunately its just too easy to go with $EDITOR's default C-style. Mea culpa, hard tab fan and several other bracket related sins contrary to the style guide. I used to have a .emacs rule to put me on the straight and narrow, but ... just another offender.

@mmosca
Copy link
Collaborator

mmosca commented Aug 6, 2023

Unfortunately its just too easy to go with $EDITOR's default C-style. Mea culpa, hard tab fan and several other bracket related sins contrary to the style guide. I used to have a .emacs rule to put me on the straight and narrow, but ... just another offender.

I am not against having .emacs .vimrc files in the repo to try to enforce desired behavior as default.

mmosca added a commit that referenced this issue Aug 6, 2023
Tab and curly bracket settings for vscode

I am not an emacs user, so I will let @stronnag add his .emacs file

Should help address #9173
@MrD-RC
Copy link
Collaborator

MrD-RC commented Aug 22, 2023

A nice little tip for VSCode

To convert existing indentation from spaces to tabs hit Ctrl+Shift+P and type: Convert indentation to Tabs

@RomanLut
Copy link
Contributor

Note: Please do not waste time fixing tabs in HITL-related code; they are fixed in PR: #8347
(sorry noticed tab problem too late)

sensei-hacker pushed a commit to sensei-hacker/inav_unofficial_targets that referenced this issue Oct 4, 2023
Tab and curly bracket settings for vscode

I am not an emacs user, so I will let @stronnag add his .emacs file

Should help address iNavFlight#9173
@iNavFlight iNavFlight locked and limited conversation to collaborators Mar 23, 2024
@b14ckyy b14ckyy converted this issue into discussion #9837 Mar 23, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

5 participants