Code Monkey home page Code Monkey logo

Comments (18)

ammarfaizi2 avatar ammarfaizi2 commented on July 29, 2024

I think we can write something up. It shouldn't be too hard for indentation checking.

Static analyzer with simple PHP or Python or Perl script can do this.

from gnuweebbot.

ammarfaizi2 avatar ammarfaizi2 commented on July 29, 2024

Just for fun, I did something really quick in awk:

{ state = 1 }
/^\x20+/ { state = 0 }
{ if (state == 0) print "Wrong indentation character"; }

Which is incomprehensible line noise. Also it doesn't show the line number where the thing goes wrong.

That thing is excessively stupid, in other words, but hey, it's good to see "ok, what does that tell us". We have wrong indentation character.

from gnuweebbot.

nrudesu avatar nrudesu commented on July 29, 2024

@im-fernanda confirm to me want to write it

from gnuweebbot.

nrudesu avatar nrudesu commented on July 29, 2024

So @im-fernanda, give us some detail about this.
Do you need another repository, or this repository is enough for you?

from gnuweebbot.

 avatar commented on July 29, 2024

I will tell you the details later when this actually works because I'm not completely sure if it can be used normally.

from gnuweebbot.

nrudesu avatar nrudesu commented on July 29, 2024

Okay fine, we will wait about this

from gnuweebbot.

ammarfaizi2 avatar ammarfaizi2 commented on July 29, 2024

@nrudesu

Do you need another repository, or this repository is enough for you?

Create another branch on this repository is okay?
I can start to initialize and wire this part up if you want to.

from gnuweebbot.

siarie avatar siarie commented on July 29, 2024

Ok, so the most problem is about indentation?
Have you ever heard about editorconfig. It's not a linter anyway.

The website says:

EditorConfig helps maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs.

I use it a lot and it's enough to solve the problem (especially for indentation).

Having a linter will make it much better. But if you want a quick solution, maybe editorconfig can be consideration.

from gnuweebbot.

ammarfaizi2 avatar ammarfaizi2 commented on July 29, 2024

@siarie how would you integrate editorconfig with CI (GitHub Workflow)?

from gnuweebbot.

ammarfaizi2 avatar ammarfaizi2 commented on July 29, 2024

I took a look at this editorconfig/editorconfig.github.com#48
It seems to be GitHub web editor rather than static analysis in CI which will yield a failure message when wrong indentation is found.

from gnuweebbot.

siarie avatar siarie commented on July 29, 2024

how would you integrate editorconfig with CI (GitHub Workflow)?

I don't know about CI stuff. I just use editorconfig on my editor/IDE.

If you looking for static analysis check this out.

Another reference:

from gnuweebbot.

nrudesu avatar nrudesu commented on July 29, 2024

@im-fernanda confirm to me want to write it

@im-fernanda changes the mind, he want to use existing lint program, so I edited the issue descriptions and @im-fernanda please tell us about ur idea

Create another branch on this repository is okay?
I can start to initialize and wire this part up if you want to.

Okay

cpplint?

hmmm, thinking...

from gnuweebbot.

ammarfaizi2 avatar ammarfaizi2 commented on July 29, 2024

@siarie looks good to me. I am playing around with cpplint right now.

ammarfaizi2@integral:~/project/now/GNUWeebBot$ for i in $(find src/gwbot -name '*.c'); do python3 ~/project/now/cpplint/cpplint.py  --filter=-whitespace/tab,-whitespace/braces,+whitespace/indent,+whitespace/line_length $i; done;
Click me!
ammarfaizi2@integral:~/project/now/GNUWeebBot$ for i in $(find src/gwbot -name '*.c'); do python3 ~/project/now/cpplint/cpplint.py  --filter=-whitespace/tab,-whitespace/braces,+whitespace/indent,+whitespace/line_length $i; done;
src/gwbot/db.c:0:  No copyright message found.  You should have a line: "Copyright [year] "  [legal/copyright] [5]
Done processing src/gwbot/db.c
Total errors found: 1
src/gwbot/argv.c:0:  No copyright message found.  You should have a line: "Copyright [year] "  [legal/copyright] [5]
Done processing src/gwbot/argv.c
Total errors found: 1
src/gwbot/print.c:77:  Consider using localtime_r(...) instead of localtime(...) for improved thread safety.  [runtime/threadsafe_fn] [2]
src/gwbot/print.c:78:  Consider using asctime_r(...) instead of asctime(...) for improved thread safety.  [runtime/threadsafe_fn] [2]
Done processing src/gwbot/print.c
Total errors found: 2
src/gwbot/gwbot.c:255:  Line ends in whitespace.  Consider deleting these extra spaces.  [whitespace/end_of_line] [4]
src/gwbot/gwbot.c:730:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/gwbot/gwbot.c:733:  Redundant blank line at the start of a code block should be deleted.  [whitespace/blank_line] [2]
src/gwbot/gwbot.c:1084:  Redundant blank line at the start of a code block should be deleted.  [whitespace/blank_line] [2]
src/gwbot/gwbot.c:1231:  Redundant blank line at the end of a code block should be deleted.  [whitespace/blank_line] [3]
Done processing src/gwbot/gwbot.c
Total errors found: 5
Done processing src/gwbot/lib/shell.c
src/gwbot/lib/tg_event.c:0:  No copyright message found.  You should have a line: "Copyright [year] "  [legal/copyright] [5]
src/gwbot/lib/tg_event.c:23:  Using C-style cast.  Use static_cast(...) instead  [readability/casting] [4]
src/gwbot/lib/tg_event.c:108:  Line ends in whitespace.  Consider deleting these extra spaces.  [whitespace/end_of_line] [4]
src/gwbot/lib/tg_event.c:112:  Line ends in whitespace.  Consider deleting these extra spaces.  [whitespace/end_of_line] [4]
src/gwbot/lib/tg_event.c:175:  Line ends in whitespace.  Consider deleting these extra spaces.  [whitespace/end_of_line] [4]
Done processing src/gwbot/lib/tg_event.c
Total errors found: 5
src/gwbot/lib/tg_api/pin_chat_message.c:0:  No copyright message found.  You should have a line: "Copyright [year] "  [legal/copyright] [5]
Done processing src/gwbot/lib/tg_api/pin_chat_message.c
Total errors found: 1
src/gwbot/lib/tg_api/kick_chat_member.c:0:  No copyright message found.  You should have a line: "Copyright [year] "  [legal/copyright] [5]
Done processing src/gwbot/lib/tg_api/kick_chat_member.c
Total errors found: 1
src/gwbot/lib/tg_api/get_chat_administrators.c:0:  No copyright message found.  You should have a line: "Copyright [year] "  [legal/copyright] [5]
Done processing src/gwbot/lib/tg_api/get_chat_administrators.c
Total errors found: 1
src/gwbot/lib/tg_api/unpin_chat_message.c:0:  No copyright message found.  You should have a line: "Copyright [year] "  [legal/copyright] [5]
Done processing src/gwbot/lib/tg_api/unpin_chat_message.c
Total errors found: 1
src/gwbot/lib/tg_api/unban_chat_member.c:0:  No copyright message found.  You should have a line: "Copyright [year] "  [legal/copyright] [5]
Done processing src/gwbot/lib/tg_api/unban_chat_member.c
Total errors found: 1
src/gwbot/lib/tg_api/send_message.c:0:  No copyright message found.  You should have a line: "Copyright [year] "  [legal/copyright] [5]
src/gwbot/lib/tg_api/send_message.c:42:  Almost always, snprintf is better than strcpy  [runtime/printf] [4]
Done processing src/gwbot/lib/tg_api/send_message.c
Total errors found: 2
src/gwbot/lib/tg_api/restrict_chat_member.c:0:  No copyright message found.  You should have a line: "Copyright [year] "  [legal/copyright] [5]
Done processing src/gwbot/lib/tg_api/restrict_chat_member.c
Total errors found: 1
src/gwbot/lib/tg_api.old.c:0:  No copyright message found.  You should have a line: "Copyright [year] "  [legal/copyright] [5]
Done processing src/gwbot/lib/tg_api.old.c
Total errors found: 1
src/gwbot/lib/tg_api.c:0:  No copyright message found.  You should have a line: "Copyright [year] "  [legal/copyright] [5]
src/gwbot/lib/tg_api.c:143:  Line ends in whitespace.  Consider deleting these extra spaces.  [whitespace/end_of_line] [4]
src/gwbot/lib/tg_api.c:186:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
Done processing src/gwbot/lib/tg_api.c
Total errors found: 3
src/gwbot/lib/arena.c:42:  Using C-style cast.  Use reinterpret_cast(...) instead  [readability/casting] [4]
Done processing src/gwbot/lib/arena.c
Total errors found: 1
src/gwbot/lib/string.c:34:  Using C-style cast.  Use reinterpret_cast(...) instead  [readability/casting] [4]
src/gwbot/lib/string.c:68:  Empty loop bodies should use {} or continue  [whitespace/empty_loop_body] [5]
Done processing src/gwbot/lib/string.c
Total errors found: 2
Done processing src/gwbot/event_logger.c
src/gwbot/main.c:0:  No copyright message found.  You should have a line: "Copyright [year] "  [legal/copyright] [5]
Done processing src/gwbot/main.c
Total errors found: 1
src/gwbot/help.c:0:  No copyright message found.  You should have a line: "Copyright [year] "  [legal/copyright] [5]
Done processing src/gwbot/help.c
Total errors found: 1
src/gwbot/modules/003_admin/admin.c:17:  Include the directory when naming .h files  [build/include_subdir] [4]
src/gwbot/modules/003_admin/admin.c:108:  Weird number of spaces at line-start.  Are you using a 2-space indent?  [whitespace/indent] [3]
src/gwbot/modules/003_admin/admin.c:117:  Line ends in whitespace.  Consider deleting these extra spaces.  [whitespace/end_of_line] [4]
src/gwbot/modules/003_admin/admin.c:177:  If you can, use sizeof(reply_text) instead of 128 as the 2nd arg to snprintf.  [runtime/printf] [3]
src/gwbot/modules/003_admin/admin.c:186:  If you can, use sizeof(reply_text) instead of 128 as the 2nd arg to snprintf.  [runtime/printf] [3]
src/gwbot/modules/003_admin/admin.c:195:  If you can, use sizeof(reply_text) instead of 128 as the 2nd arg to snprintf.  [runtime/printf] [3]
src/gwbot/modules/003_admin/admin.c:203:  If you can, use sizeof(reply_text) instead of 128 as the 2nd arg to snprintf.  [runtime/printf] [3]
src/gwbot/modules/003_admin/admin.c:548:  Line ends in whitespace.  Consider deleting these extra spaces.  [whitespace/end_of_line] [4]
src/gwbot/modules/003_admin/admin.c:621:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/gwbot/modules/003_admin/admin.c:668:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/gwbot/modules/003_admin/admin.c:703:  Redundant blank line at the start of a code block should be deleted.  [whitespace/blank_line] [2]
src/gwbot/modules/003_admin/admin.c:871:  Redundant blank line at the start of a code block should be deleted.  [whitespace/blank_line] [2]
src/gwbot/modules/003_admin/admin.c:909:  Redundant blank line at the start of a code block should be deleted.  [whitespace/blank_line] [2]
src/gwbot/modules/003_admin/admin.c:931:  Redundant blank line at the start of a code block should be deleted.  [whitespace/blank_line] [2]
src/gwbot/modules/003_admin/admin.c:933:  Redundant blank line at the start of a code block should be deleted.  [whitespace/blank_line] [2]
Done processing src/gwbot/modules/003_admin/admin.c
Total errors found: 15
src/gwbot/modules/000_debug/debug.c:19:  Include the directory when naming .h files  [build/include_subdir] [4]
src/gwbot/modules/000_debug/debug.c:47:  Line ends in whitespace.  Consider deleting these extra spaces.  [whitespace/end_of_line] [4]
src/gwbot/modules/000_debug/debug.c:95:  Using C-style cast.  Use reinterpret_cast(...) instead  [readability/casting] [4]
Done processing src/gwbot/modules/000_debug/debug.c
Total errors found: 3
src/gwbot/modules/002_translate/translate.c:18:  Include the directory when naming .h files  [build/include_subdir] [4]
src/gwbot/modules/002_translate/translate.c:318:  Lines should be <= 80 characters long  [whitespace/line_length] [2]
src/gwbot/modules/002_translate/translate.c:397:  If an else has a brace on one side, it should have it on both  [readability/braces] [5]
Done processing src/gwbot/modules/002_translate/translate.c
Total errors found: 3
src/gwbot/modules/001_standard/standard.c:18:  Include the directory when naming .h files  [build/include_subdir] [4]
Done processing src/gwbot/modules/001_standard/standard.c
Total errors found: 1
src/gwbot/routes.c:0:  No copyright message found.  You should have a line: "Copyright [year] "  [legal/copyright] [5]
Done processing src/gwbot/routes.c
Total errors found: 1
src/gwbot/event_handler.c:0:  No copyright message found.  You should have a line: "Copyright [year] "  [legal/copyright] [5]
src/gwbot/event_handler.c:7:  Include the directory when naming .h files  [build/include_subdir] [4]
Done processing src/gwbot/event_handler.c
Total errors found: 2
src/gwbot/config.c:44:  If an else has a brace on one side, it should have it on both  [readability/braces] [5]
src/gwbot/config.c:47:  If an else has a brace on one side, it should have it on both  [readability/braces] [5]
src/gwbot/config.c:51:  If an else has a brace on one side, it should have it on both  [readability/braces] [5]
src/gwbot/config.c:54:  If an else has a brace on one side, it should have it on both  [readability/braces] [5]
src/gwbot/config.c:57:  If an else has a brace on one side, it should have it on both  [readability/braces] [5]
src/gwbot/config.c:60:  If an else has a brace on one side, it should have it on both  [readability/braces] [5]
src/gwbot/config.c:63:  If an else has a brace on one side, it should have it on both  [readability/braces] [5]
src/gwbot/config.c:66:  If an else has a brace on one side, it should have it on both  [readability/braces] [5]
src/gwbot/config.c:72:  If an else has a brace on one side, it should have it on both  [readability/braces] [5]
src/gwbot/config.c:76:  If an else has a brace on one side, it should have it on both  [readability/braces] [5]
src/gwbot/config.c:79:  If an else has a brace on one side, it should have it on both  [readability/braces] [5]
src/gwbot/config.c:85:  If an else has a brace on one side, it should have it on both  [readability/braces] [5]
Done processing src/gwbot/config.c
Total errors found: 12
ammarfaizi2@integral:~/project/now/GNUWeebBot$ 

from gnuweebbot.

 avatar commented on July 29, 2024

Previously i had an idea how to use flake8 but i thought it was too bloat because he needs a lot of pre requisites dependencies, but I think it is easier to integrate with CI.

reference https://flake8.pycqa.org/en/latest/

from gnuweebbot.

ammarfaizi2 avatar ammarfaizi2 commented on July 29, 2024

@im-fernanda can you try flake8 to examine current codebase and send me the output?
Would like to see how is the output compared to the cpplint.

from gnuweebbot.

siarie avatar siarie commented on July 29, 2024

@im-fernanda isn't flake8 for python?

@ammarfaizi2 check editorconfig-checker for Continuous Integration.

from gnuweebbot.

 avatar commented on July 29, 2024

@im-fernanda isn't flake8 for python?

linter for all languages not python only

from gnuweebbot.

nrudesu avatar nrudesu commented on July 29, 2024

@im-fernanda changes the mind, he want to use existing lint program, so I edited the issue descriptions and @im-fernanda please tell us about ur idea

seriously, @im-fernanda makes me confuse, lmao. but finally he write his own linter. I already fork it.

https://github.com/GNUWeeb/linter-C

from gnuweebbot.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.