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

bears/c_languages: Add ArtisticStyleBear #1882

Merged
merged 1 commit into from Jul 21, 2017
Merged

Conversation

@yash-nisar
Copy link
Member

yash-nisar commented Jul 3, 2017

Closes #388

For short term contributors: we understand that getting your commits well
defined like we require is a hard task and takes some learning. If you
look to help without wanting to contribute long term there's no need
for you to learn this. Just drop us a message and we'll take care of brushing
up your stuff for merge!

Checklist

  • I read the commit guidelines and I've followed
    them.
  • I ran coala over my code locally. (All commits have to pass
    individually.
    It is not sufficient to have "fixup commits" on your PR,
    our bot will still report the issues for the previous commit.) You will
    likely receive a lot of bot comments and build failures if coala does not
    pass on every single commit!

After you submit your pull request, DO NOT click the 'Update Branch' button.
When asked for a rebase, consult coala.io/rebase
instead.

Please consider helping us by reviewing other peoples pull requests as well:

The more you review, the more your score will grow at coala.io and we will
review your PRs faster!

.ci/deps.sh Outdated
tar xf ~/astyle.tar.gz -C ~/
cd ~/astyle/build/gcc
make
fi

This comment has been minimized.

@gitmate-bot

gitmate-bot Jul 3, 2017 Collaborator

Line contains following spacing inconsistencies:

  • No newline at EOF.

SpaceConsistencyBear, severity NORMAL, section ci.

The issue can be fixed by applying the following patch:

--- a/.ci/deps.sh
+++ b/.ci/deps.sh
@@ -62,4 +62,4 @@
   tar xf ~/astyle.tar.gz -C ~/
   cd ~/astyle/build/gcc
   make
-fi+fi
@yash-nisar yash-nisar force-pushed the yash-nisar:astyle-bear branch from 5d23efb to 77a20cd Jul 3, 2017
break_one_line_headers: bool=False,
add_braces_to_one_line_conditionals: bool=False,
remove_braces_from_one_line_conditionals: bool=False,
remove_comment_prefix: bool=True):

This comment has been minimized.

@yash-nisar

yash-nisar Jul 4, 2017 Author Member

Custom config file argument missing, see http://astyle.sourceforge.net/astyle.html#_Options_File

This comment has been minimized.

@Makman2

Makman2 Jul 10, 2017 Member

hm there's --options, or what do you mean?

This comment has been minimized.

@yash-nisar

yash-nisar Jul 10, 2017 Author Member

I mean I have to provide an argument called as astyle_config_file, will do it in the review iteration. 😉

This comment has been minimized.

@Makman2

Makman2 Jul 11, 2017 Member

another PR :)

This comment has been minimized.

@yash-nisar

yash-nisar Jul 11, 2017 Author Member

Done 👍

attach_braces_to_namespace: bool=True,
attach_braces_to_class: bool=True,
attach_braces_to_inline: bool=True,
attach_braces_to_extern: bool=False,

This comment has been minimized.

@AsnelChristian

AsnelChristian Jul 4, 2017 Member

settings' names usually start with either allow, prohibit or use would you follow that convention ? this is super important as it is part of settings unification

This comment has been minimized.

This comment has been minimized.

@Makman2

Makman2 Jul 20, 2017 Member

@yash-nisar bump again :)

This comment has been minimized.

@yash-nisar

yash-nisar Jul 21, 2017 Author Member

Fixed. 👍

bar()
return 1; }
else
return 0; }

This comment has been minimized.

@AsnelChristian

AsnelChristian Jul 4, 2017 Member

can you shorten this... maybe providing us the list of all ppossible values for this settting along with fewer examples and more tests would do the trick.

This comment has been minimized.

@Makman2

Makman2 Jul 10, 2017 Member

I actually don't have something against this longer documentation, but we definitely need some header line that summarizes the possible values and their meanings in a few sentences 👍

return 0; }
:param use_spaces:
In the following examples, q space is indicated with a . (dot), a

This comment has been minimized.

@AsnelChristian

AsnelChristian Jul 4, 2017 Member

q -> q; . -> .

This comment has been minimized.

@AsnelChristian

AsnelChristian Jul 4, 2017 Member

missing documentation ion this parameter, (and this shoulb be said after the doc)

This comment has been minimized.

@yash-nisar

yash-nisar Jul 11, 2017 Author Member

Addressed 👍

........bar();
}
For example: If set to ``True``, spaces will be used for

This comment has been minimized.

@AsnelChristian

AsnelChristian Jul 4, 2017 Member

If True spaces will be used.
Example:: (should be a code if not example is not needed

For example: If set to ``True``, spaces will be used for
indentation.
For example: If set to ``False``, tabs will be used for
indentation, and spaces for continuation line alignment as below::

This comment has been minimized.

@AsnelChristian

AsnelChristian Jul 4, 2017 Member

same here

}
:param indent_size:
Specifies the number of spaces per indent.

This comment has been minimized.

@AsnelChristian

AsnelChristian Jul 4, 2017 Member

Number of spaces per indentation level use the same docs as in the other bears

This comment has been minimized.

@yash-nisar

yash-nisar Jul 11, 2017 Author Member

Addressed 👍

@yash-nisar yash-nisar force-pushed the yash-nisar:astyle-bear branch from 77a20cd to f484e9b Jul 5, 2017
@yash-nisar
Copy link
Member Author

yash-nisar commented Jul 6, 2017

@Makman2 Please have a look when you're free 😉

@yash-nisar yash-nisar force-pushed the yash-nisar:astyle-bear branch 5 times, most recently from dd81188 to 0678801 Jul 6, 2017
@yash-nisar
Copy link
Member Author

yash-nisar commented Jul 6, 2017

Can you help me out with the appveyor build failure ? @Makman2

@yash-nisar
Copy link
Member Author

yash-nisar commented Jul 6, 2017

An uncached CircleCI build passes whereas a cached build fails. Note that TravisCI builds pass.

args.append(indent + '=' + str(indent_size))
for k, v in rules_map.items():
if v:
args.append(k)

This comment has been minimized.

@Makman2

Makman2 Jul 10, 2017 Member

can be shortened:

args += (k for k, v in rules_map.items() if v)  # don't use [] to prevent creating a intermediate list.
else:
indent = '--indent=tab'
if indent is not None:
args.append(indent + '=' + str(indent_size))

This comment has been minimized.

@Makman2

Makman2 Jul 10, 2017 Member

maybe create another dict for these value-parameters?

settings_map = {'--indent': None if use_spaces is None else 'spaces' is use_spaces else 'tab'} # <-- maybe you can beautify the if else expression a bit ;D
# You could also add `--style`

args += (k for k, v in settings_map.items() if v) # or: if v is not None, not sure what's better now
.ci/deps.sh Outdated
wget "https://downloads.sourceforge.net/project/astyle/astyle/astyle%203.0.1/astyle_3.0.1_linux.tar.gz?r=&ts=1499017588&use_mirror=excellmedia" -O ~/astyle.tar.gz
tar -xvzf ~/astyle.tar.gz -C ~/
cd ~/astyle/build/gcc
make

This comment has been minimized.

@Makman2

Makman2 Jul 10, 2017 Member

it's not shipped prebuilt? :O

This comment has been minimized.

@yash-nisar

yash-nisar Jul 11, 2017 Author Member

It is shipped prebuilt but the version spec is low i.e. 2.03-1, see https://packages.ubuntu.com/trusty/astyle.

Our CI also uses trusty for which we would have to install the version 2.03-1, which is pretty old IMO. For installing the latest version, building it is the only method.

This comment has been minimized.

@Makman2

Makman2 Jul 11, 2017 Member

ah kk, but I meant when you download the tar.gz file, aren't there some precompiled binaries inside?

This comment has been minimized.

@yash-nisar

yash-nisar Jul 11, 2017 Author Member

Nope, the ...bin folder is generated once we build it.

.ci/deps.sh Outdated
if [ ! -e ~/astyle/build/gcc/bin/astyle ]; then
wget "https://downloads.sourceforge.net/project/astyle/astyle/astyle%203.0.1/astyle_3.0.1_linux.tar.gz?r=&ts=1499017588&use_mirror=excellmedia" -O ~/astyle.tar.gz
tar -xvzf ~/astyle.tar.gz -C ~/
cd ~/astyle/build/gcc

This comment has been minimized.

@Makman2

Makman2 Jul 10, 2017 Member

after making astyle you should step out again into the previous working directory to prevent weird errors for coming installations. Or use the -C/--directory flag of make.

"""

LANGUAGES = {'C', 'C++', 'Objective-C', 'C#', 'Java'}
REQUIREMENTS = {DistributionRequirement(apt_get='astyle')}

This comment has been minimized.

@Makman2

Makman2 Jul 10, 2017 Member

astyle is also available for dnf in Fedora 26 :)

@yash-nisar yash-nisar force-pushed the yash-nisar:astyle-bear branch from 0678801 to 2f74f8a Jul 11, 2017
@yash-nisar
Copy link
Member Author

yash-nisar commented Jul 11, 2017

@Makman2 How do the changes look now ?

@Makman2
Copy link
Member

Makman2 commented Jul 11, 2017

@yash-nisar your tests fail :O

'--remove-brackets': remove_braces_from_one_line_conditionals,
'--remove-comment-prefix': remove_comment_prefix
}
args = ('--suffix=none', '--dry-run')

This comment has been minimized.

@Makman2

Makman2 Jul 11, 2017 Member

use a list, that's faster to append to

This comment has been minimized.

@yash-nisar

yash-nisar Jul 11, 2017 Author Member

Done 👍

if use_spaces is True:
args += (''.join(('-s', str(indent_size))),)
elif use_spaces is False:
args += (''.join(('-t', str(indent_size))),)

This comment has been minimized.

@Makman2

Makman2 Jul 11, 2017 Member

why not using another dict for this kind of parameters like I suggested before?

args += (''.join(('-t', str(indent_size))),)
for k, v in rules_map.items():
if v:
args += (k,)

This comment has been minimized.

@Makman2

Makman2 Jul 11, 2017 Member

like said before, can be shortened:

args += (k for k, v in rules_map.items() if v)

This comment has been minimized.

@yash-nisar

yash-nisar Jul 11, 2017 Author Member

Awesome 👍

@yash-nisar yash-nisar force-pushed the yash-nisar:astyle-bear branch from 2f74f8a to aaaae51 Jul 11, 2017
}
args = ['--suffix=none', '--dry-run']
if bracket_style:
args += (''.join(('--style=', bracket_style)),)

This comment has been minimized.

@Makman2

Makman2 Jul 11, 2017 Member

use args.append, makes the command shorter

This comment has been minimized.

@Makman2

Makman2 Jul 11, 2017 Member

and I don't think you need to use join for just two values, I think this is easier and better to read ;)

args.append('--style=' + bracket_style)

This comment has been minimized.

@Makman2

Makman2 Jul 11, 2017 Member

same below

@yash-nisar yash-nisar force-pushed the yash-nisar:astyle-bear branch from aaaae51 to 5b27735 Jul 11, 2017
return 0;
}
For example: ``Banner`` style uses attached, indented braces. Switch

This comment has been minimized.

@gitmate-bot

gitmate-bot Jul 19, 2017 Collaborator

Line is longer than allowed. (80 > 79)

LineLengthBear, severity NORMAL, section linelength.

return 0;
}
For example: ``Whitesmith`` style uses broken, indented braces. Switch

This comment has been minimized.

@gitmate-bot

gitmate-bot Jul 19, 2017 Collaborator

Line is longer than allowed. (82 > 79)

LineLengthBear, severity NORMAL, section linelength.

return 0;
}
For example: ``Banner`` style uses attached, indented braces. Switch

This comment has been minimized.

@gitmate-bot

gitmate-bot Jul 19, 2017 Collaborator

E501 line too long (80 > 79 characters)'

PycodestyleBear (E501), severity NORMAL, section autopep8.

return 0;
}
For example: ``Whitesmith`` style uses broken, indented braces. Switch

This comment has been minimized.

@gitmate-bot

gitmate-bot Jul 19, 2017 Collaborator

E501 line too long (82 > 79 characters)'

PycodestyleBear (E501), severity NORMAL, section autopep8.

@yash-nisar yash-nisar force-pushed the yash-nisar:astyle-bear branch from 87fd993 to 8b58180 Jul 19, 2017
.ci/deps.sh Outdated
@@ -55,3 +55,11 @@ if [ ! -e ~/phpmd/phpmd ]; then
sudo chmod +x phpmd.phar
sudo mv phpmd.phar ~/phpmd/phpmd
fi

# astyle installation
if [ ! -e ~/astyle/build/gcc/bin/astyle ]; then

This comment has been minimized.

@Makman2

Makman2 Jul 20, 2017 Member

as you don't seem to cache at all currently, you don't need the if ;)

@yash-nisar
Copy link
Member Author

yash-nisar commented Jul 20, 2017

@Makman2 Did you notice that the tests have passed and we have no idea why ? 😛

@yash-nisar
Copy link
Member Author

yash-nisar commented Jul 20, 2017

They pass whenever they want to. 😛

Possible values are ``allman, java, kr, stroustrup, whitesmith,
vtk, banner, gnu, linux, horstmann, google, mozilla, pico and
lisp.``
For example: Allman style uses braces that are broken from the

This comment has been minimized.

@AsnelChristian

AsnelChristian Jul 20, 2017 Member

``Allman style``

This comment has been minimized.

@Makman2

Makman2 Jul 20, 2017 Member

Hm not sure, then rather

``allman`` style

to refer to the actual keyword/parameter

This comment has been minimized.

@yash-nisar

yash-nisar Jul 21, 2017 Author Member

See #1882 (comment). Referring to the actual keyword/parameter may cause problems in some cases like Kernighan & Ritchie. The actual keyword is referred to as kr so replacing Kernighan & Ritchie with kr may make it difficult for users to understand the style name.

@AsnelChristian
Copy link
Member

AsnelChristian commented Jul 20, 2017

aren't they passing locally ?

@Nosferatul
Copy link
Member

Nosferatul commented Jul 20, 2017

@yash-nisar why the tests have passed because of your tests, right?

@Makman2
Copy link
Member

Makman2 commented Jul 20, 2017

@AsnelChristian we had strange caching problems. Cached runs just didn't pass, although everything seemed to be set up correctly (we did the same like for other applications). However we will file an issue to implement caching again, so we can at least get something merged.

@yash-nisar yash-nisar force-pushed the yash-nisar:astyle-bear branch from 8b58180 to f4c7789 Jul 21, 2017
@yash-nisar
Copy link
Member Author

yash-nisar commented Jul 21, 2017

Updated with the required changes @Makman2 @AsnelChristian

@yash-nisar
Copy link
Member Author

yash-nisar commented Jul 21, 2017

Lets see if the tests pass on CI, if they don't I'll remove the if condition in deps.sh.

@yash-nisar yash-nisar force-pushed the yash-nisar:astyle-bear branch from f4c7789 to 19e5337 Jul 21, 2017
@yash-nisar
Copy link
Member Author

yash-nisar commented Jul 21, 2017

Bam The problem is now gone 👍 @Makman2

Closes #388
@yash-nisar yash-nisar force-pushed the yash-nisar:astyle-bear branch from 19e5337 to 65d6304 Jul 21, 2017
break_one_line_headers: bool=False,
require_braces_at_one_line_conditionals: bool=False,
prohibit_braces_from_one_line_conditionals:
bool=False,

This comment has been minimized.

@Makman2

Makman2 Jul 21, 2017 Member

indent by 4 spaces

this is invalid PEP8 it seems

@Makman2
Copy link
Member

Makman2 commented Jul 21, 2017

ack 65d6304

@Makman2
Copy link
Member

Makman2 commented Jul 21, 2017

ack 65d6304

@Makman2
Copy link
Member

Makman2 commented Jul 21, 2017

@rultor merge

@rultor
Copy link

rultor commented Jul 21, 2017

@rultor merge

@Makman2 OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit 65d6304 into coala:master Jul 21, 2017
6 of 8 checks passed
6 of 8 checks passed
ci/circleci CircleCI is running your tests
Details
continuous-integration/appveyor/branch Waiting for AppVeyor build to complete
Details
codecov/project 100% (target 100%)
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
review/gitmate/commit No issues with this one - go ahead! :)
Details
review/gitmate/manual This commit was acknowledged.
Details
review/gitmate/pr All is well! :) (0 problems solved)
Details
@yash-nisar yash-nisar deleted the yash-nisar:astyle-bear branch Jul 21, 2017
@rultor
Copy link

rultor commented Jul 21, 2017

@rultor merge

@Makman2 Done! FYI, the full log is here (took me 2min)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked issues

Successfully merging this pull request may close these issues.

7 participants
You can’t perform that action at this time.