GithubHelp home page GithubHelp logo

holbertonschool / betty Goto Github PK

View Code? Open in Web Editor NEW
1.3K 80.0 1.8K 588 KB

Holberton-style C code checker written in Perl

License: GNU General Public License v3.0

Perl 91.03% Shell 1.58% C 7.39%
coding-style betty holberton c

betty's Introduction

Betty

Build Status

Installation

Run the script install.sh with sudo privileges to install betty-style and betty-doc on your computer, along with the following manuals:

  • betty(1)
  • betty-style(1)
  • betty-doc(1)

Documentation

Please visit the Betty Wiki for the full specifications of Betty coding and documentation styles.

You'll also find some references and some tools for common text editors such as Emacs and Atom.

Usage

Run the following command to check if your code/doc fits the Betty Style (mostly inspired from the Linux Kernel style):

betty-style file1 [file2 [file3 [...]]]
betty-doc file1 [file2 [file3 [...]]]

betty's People

Contributors

dalzuga avatar dev-loup avatar dorakorpar avatar jbarbier avatar papamuziko avatar rd-feng avatar thrownblown avatar wintermanc3r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

betty's Issues

Open brace after "do"

The open brace after a do should be on the same line, as follows:

do {
    something();
} while (condition);

Problem with betty-doc and betty-style in some linux distributions.

Hi, I'm Kevin from Colombia.
I want to report two problems that I have with the use of Betty, after I did the installation.
The left parenthesis without leaks in regex is deprecated here (and will be fatal in Perl 5.32), passed in regex; marked by <- HERE in m / ({<- HERE) / at / usr / local / bin / betty-style line 3908, and marked by <- HERE in m / ({<- HERE. *}) / en / usr / local / bin / betty-doc line 2038.
I solved it by opening, with write permissions, each of those files and removing the braces that conflict with those lines.

The operating system I had problems with is Kali Linux 64 bits, version 2019.3

I leave it written for those who agree with the error and come to read a possible solution.
Thank you.

mandb Command Not Found on macOS During Installation

Problem:

The installation script for Betty includes the mandb command, which is not available on macOS. This results in an error message (mandb: command not found) when the script is run on a macOS system.

Impact:

This issue causes confusion and may lead users to believe that the installation process has failed, even though Betty is
installed correctly.

Proposed Solution:

Modify the installation script to check the operating system type. If the script detects macOS (darwin), it should skip the mandb command and display a message indicating that this step is not necessary. On Linux systems, the script should execute mandb as usual.

Testing:

The modified script has been tested on both macOS and Linux systems to ensure that it behaves as expected, skipping the mandb command on macOS and executing it on Linux.

Link to Issue

Addresses issue #60.

echo $? -> 0

Hi How are you?
I was trying to do a script that use betty, but I need to check if betty throws and error, but with this code, she says that there is an error, but when I check the exit status $? it says that there is no error. Is this a bug?

image

BETTY WARNING: "unnecessary whitespace before a quoted newline"

Not a huge issue, but the following line triggers a warning from betty:
#define DELIM " \n\t"
... see the warning as quoted in the subject ...
I do a workaround by placing the space character between the newline and tab chars like so:
#define DELIM "\n \t"

<$CFILE>

alx_low_level_programming

0×00_hello_world

More than 5 functions wrong detection

This kind of declaration is detected as functions by Betty

KeyBind binded_keys[] = {
    {0x4F, RIGHT_FLAG, &turn_right},
    {0x50, LEFT_FLAG, &turn_left},
    {0x1A, W_FLAG, &move_front},
    {0x16, S_FLAG, &move_back},
    {0x04, A_FLAG, &move_left},
    {0x07, D_FLAG, &move_right},
    {0, -1, NULL}
};

WARNING: Prefer 'signed int' to bare use of 'signed'

char *handle_d_i_specifier(const conversion_specification_t *spec,
va_list argptr)
{
char *formatted_value = NULL, *temp = NULL;
signed long int d, len;
char sp = spec != NULL ? spec->conversion_specifier : 'Z';

    if (sp == 'd' || sp == 'i')
    {
            d = handle_len_mod_for_signed(spec, argptr);

//////////////////////////////////////////////////////

long int handle_len_mod_for_signed(const conversion_specification_t *spec,
va_list argptr)
{
long int value;

    if (spec->length_modifier == NULL)
            value = va_arg(argptr, int);
    else if (spec->length_modifier[0] == 'h')
            value = (short int)va_arg(argptr, int);

Issue when running on VS Code ubuntu 20

perl send warnings about deprecated syntax

Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.32), passed through in regex; marked by <-- HERE in m/({ <-- HERE )/ at /usr/local/bin/betty-style line 3916.
Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.32), passed through in regex; marked by <-- HERE in m/({ <-- HERE .*})/ at /usr/local/bin/betty-doc line 2038.

Betty does not support array pointer syntax in function documentation

Pointer to array syntax such as int (*array)[10] is not supported for function parameters.

For example, the following code throws the following warnings, indicating that the parameter listint_t *(*buckets)[10] is not parsed correctly.

/**
 * alloc_buckets - dynamically allocate buckets for each digit
 *
 * @array: array of integers to be sorted
 * @size: number of elements in the array to be sorted
 * @factor: factor of digit on which to sort
 * @buckets: pointer to array of pointers to buckets
 */
static void alloc_buckets(const int *array, size_t size, int factor, listint_t *(*buckets)[10])
105-radix_sort.c:81: warning: No description found for parameter or member '(*buckets'
105-radix_sort.c:82: warning: Excess function parameter 'buckets' description in 'alloc_buckets'

Unicode characters count as 2 characters.

When using Unicode characters they count as 2 instead of one.

Researching about Unicode support in Perl, believe this is happening due to Perl
counting a Unicode character as 2 bytes depending on the character size in HEX
digits.

─────────────── How to reproduce the problem ───────────────

Here's a sample C comment 81 characters long and the same length of comment
using one Unicode character below.

ASCII comment:
/* Line # 14 A long commentary of exactly 81 characters. /
Unicode comment.
/
Line # 16, with a Unicode character ----> ─ <---- */

──────────────────── Sample image ────────────────────

Here's an attached image showing the output given by betty.

image

──────────────────── Where to look ────────────────────

By reading the Perl code, I believe the problem might be arising around the line
2813 on the conditional statemet to raise the warning message indicated here:
https://github.com/holbertonschool/Betty/blob/438f97cb63fa6ee8d6a8092a4f2fb529e238d1c9/betty-style.pl#L2813

Check header files protection

Check that header files are protected from double-inclusion like follows:

#ifndef _HEADER_FILE_H_
#define _HEADER_FILE_H_

/*
 * Declarations here
 */

#endif /* _HEADER_FILE_H_ */

False "Multiple instructions" error lead to questioning Betty's ability to see escaped double quotes

Hi all-

I found an edge case in the Betty styling that is a bit specific but might point to a general improvement for future development. When working on a project emulating sh/dash, I needed produce error messages such as:

$ ls ;; ls
sh: 1: Syntax error: ";;" unexpected

And I noticed when I had strings in my code including escaped double quotes and semicolons "\";;\"" Betty would interpret that as multiple instructions on the same line:

shell_loop.c:184: WARNING: Multiple instructions on a single line is forbidden

However, it was smart enough to disregard the semicolons when in a string without escaped quotes ";;". So it seems like in the above example it fails to see two of the quotes as escaped, and thinks instead that there are two strings with semicolons between them.

The general improvement I hinted at is that if escaped quotes are indeed not seen by Betty overall, it could be the source of other false positives for style violations inside strings.

I found the relevant section of betty-style.pl for my particular issue, seen below. I have not yet scanned the codebase to see if escaped quote blindness is an issue elsewhere.

vagrant@vagrant-ubuntu-trusty-64:~/Betty$ grep -nB 10 "Multiple instructions" betty-style.pl
3119-# check for multiple instructions on a single line
3120-           if ($rawline =~ /;/) {
3121-                   my $pure = $rawline;
3122-                   $pure =~ s/\/\*+.*//;
3123-                   $pure =~ s/.*\*+\///;
3124-                   $pure =~ s/['][^']*[']//g;
3125-                   $pure =~ s/["][^"]*["]//g;
3126-                   my $count = () = $pure =~ /;/g;
3127-                   if ($count > 1 && $pure !~ /\bfor\b/) {
3128-                           WARN("MULTI_INS",
3129:                               "Multiple instructions on a single line is forbidden\n");

Thanks for looking.

Errors in Perl 5.26.1

Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through in regex; marked by <-- HERE in m/^(.\s*){ <-- HERE \s*/ at /usr/local/bin/betty-style line 3544.
Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through in regex; marked by <-- HERE in m/^(.\s*){ <-- HERE \s*/ at /usr/local/bin/betty-style line 3974.
Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through in regex; marked by <-- HERE in m/^(\+.*(?:do|\))){ <-- HERE / at /usr/local/bin/betty-style line 4464.

80 lines limit

Some lines are detected by Betty to be longer than 80 columns, but they are shorter..

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.