[libcamera-devel,4/5] utils: checkstyle: add keep-one-line-blocks

Message ID 20181221081311.3291-5-kieran.bingham@ideasonboard.com
State Accepted
Headers show
Series
  • test: Define libtest
Related show

Commit Message

Kieran Bingham Dec. 21, 2018, 8:13 a.m. UTC
Enable --keep-one-line-blocks to prevent astyle from wanting to move
single inlined blocks to cover 4 lines such as:

-       virtual int init() { return 0; }
+       virtual int init()
+       {
+               return 0;
+       }

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 utils/checkstyle.py | 1 +
 1 file changed, 1 insertion(+)

Comments

Jacopo Mondi Dec. 21, 2018, 3:17 p.m. UTC | #1
Hi Kieran,

On Fri, Dec 21, 2018 at 08:13:10AM +0000, Kieran Bingham wrote:
> Enable --keep-one-line-blocks to prevent astyle from wanting to move
> single inlined blocks to cover 4 lines such as:
>
> -       virtual int init() { return 0; }
> +       virtual int init()
> +       {
> +               return 0;
> +       }
>

Thanks, this silences a lot of false positives for me!

Please add my tag and you can push this one in my opinion.

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

The next thing to silence would be in my opinion, astyle trying to
outsmart me when I force indent to open braces (or where I think is
more appropriate)

Eg:
 	struct media_v2_pad *pad = reinterpret_cast<struct media_v2_pad *>
-				   (topology.ptr_pads);
+					   (topology.ptr_pads);

This might be controversial though, so I would postpone this.

Thanks
   j

> ---
>  utils/checkstyle.py | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/utils/checkstyle.py b/utils/checkstyle.py
> index 32974815048a..a40d7dec879f 100755
> --- a/utils/checkstyle.py
> +++ b/utils/checkstyle.py
> @@ -29,6 +29,7 @@ astyle_options = (
>      '--pad-oper',
>      '--align-pointer=name',
>      '--align-reference=name',
> +    '--keep-one-line-blocks',
>      '--max-code-length=120'
>  )
>
> --
> 2.17.1
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Kieran Bingham Dec. 21, 2018, 3:19 p.m. UTC | #2
Hi Jacopo,

On 21/12/2018 15:17, jacopo mondi wrote:
> Hi Kieran,
> 
> On Fri, Dec 21, 2018 at 08:13:10AM +0000, Kieran Bingham wrote:
>> Enable --keep-one-line-blocks to prevent astyle from wanting to move
>> single inlined blocks to cover 4 lines such as:
>>
>> -       virtual int init() { return 0; }
>> +       virtual int init()
>> +       {
>> +               return 0;
>> +       }
>>
> 
> Thanks, this silences a lot of false positives for me!
> 
> Please add my tag and you can push this one in my opinion.
> 
> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
>> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 

Thanks, and done.


> The next thing to silence would be in my opinion, astyle trying to
> outsmart me when I force indent to open braces (or where I think is
> more appropriate)
> 
> Eg:
>  	struct media_v2_pad *pad = reinterpret_cast<struct media_v2_pad *>
> -				   (topology.ptr_pads);
> +					   (topology.ptr_pads);
> 
> This might be controversial though, so I would postpone this.

I'll leave this one to you then :)

Cheers


> 
> Thanks
>    j
> 
>> ---
>>  utils/checkstyle.py | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/utils/checkstyle.py b/utils/checkstyle.py
>> index 32974815048a..a40d7dec879f 100755
>> --- a/utils/checkstyle.py
>> +++ b/utils/checkstyle.py
>> @@ -29,6 +29,7 @@ astyle_options = (
>>      '--pad-oper',
>>      '--align-pointer=name',
>>      '--align-reference=name',
>> +    '--keep-one-line-blocks',
>>      '--max-code-length=120'
>>  )
>>
>> --
>> 2.17.1
>>
>> _______________________________________________
>> libcamera-devel mailing list
>> libcamera-devel@lists.libcamera.org
>> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/utils/checkstyle.py b/utils/checkstyle.py
index 32974815048a..a40d7dec879f 100755
--- a/utils/checkstyle.py
+++ b/utils/checkstyle.py
@@ -29,6 +29,7 @@  astyle_options = (
     '--pad-oper',
     '--align-pointer=name',
     '--align-reference=name',
+    '--keep-one-line-blocks',
     '--max-code-length=120'
 )