-
Notifications
You must be signed in to change notification settings - Fork 579
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
WIP ImageDimensionBear: Add ImageDimensionBear to coala-bears #1288
base: master
Are you sure you want to change the base?
Conversation
Thanks for your contribution! Reviewing pull requests take really a lot of time and we're all volunteers. Please make sure you go through the following check list and complete them all before pinging someone for a review.
As you learn things over your Pull Request please help others on the chat and on PRs to get their stuff right as well! |
Comment on 0498502. Shortlog of the HEAD commit contains 57 character(s). This is 7 character(s) longer than the limit (57 > 50). GitCommitBear, severity NORMAL, section |
0498502
to
d6c7738
Compare
Regarding your general problem of So the first step is splitting - def run(self, image_config):
+ def run(self, files, image_width, image_height): The benefit is that the user only needs to set This approach has one weakness compared to your The result is that the user needs to create multiple |
d6c7738
to
31d4c0e
Compare
459f081
to
40e5886
Compare
Gemfile
Outdated
@@ -7,3 +7,5 @@ gem 'scss_lint', require: false# require flag is necessary https://github.com/br | |||
gem "reek" | |||
gem "puppet-lint" | |||
gem "csvlint" | |||
gem "img_checker" | |||
gem "fastimage" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this? doesnt img_checker declare a dependency on fastimage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure, but I was having problem in running it, so I added it, and then it started working
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to add fast_image
.
bears/general/ImageDimensionBear.py
Outdated
'height': int(each[2])}] | ||
yaml.dump(config, yaml_file, default_flow_style=False) | ||
|
||
cmd = 'ruby -r "img_checker.rb" -e ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for double quotes, as there are no space characters in the filename.
bears/general/ImageDimensionBear.py
Outdated
|
||
AUTHORS = {'The coala developers'} | ||
AUTHORS_EMAILS = {'[email protected]'} | ||
REQUIREMENTS = {GemRequirement(' img_checker'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This workaround is OK for a WIP, but you need to solve the bug in GemRequirement
before this bear will be merge-able.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I have submitted a PR for that https://gitlab.com/coala/package_manager/merge_requests/10
FYI I made changes in abishekvashok/img_checker#22 -- soon as @Abhi2424shek merges and it deploys. It added an executable. so you type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work -- a few things not needed. See comments.
Gemfile
Outdated
@@ -7,3 +7,5 @@ gem 'scss_lint', require: false# require flag is necessary https://github.com/br | |||
gem "reek" | |||
gem "puppet-lint" | |||
gem "csvlint" | |||
gem "img_checker" | |||
gem "fastimage" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to add fast_image
.
bears/general/ImageDimensionBear.py
Outdated
yaml.dump(config, yaml_file, default_flow_style=False) | ||
|
||
cmd = 'ruby -r "img_checker.rb" -e ' | ||
cmd += '"ImgChecker.new.initialize img_config.yml"' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed since soon as abishekvashok/img_checker#22 is merged -- it should "just work"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is that also updated in the gem? it would be easier if so. will do the changes once its merged. thanks for informing :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't up the version number, that's for them to decide. I just cleaned things up.
40e5886
to
e0d6747
Compare
bears/general/ImageDimensionBear.py
Outdated
|
||
with open('img_config.yml', 'w') as yaml_file: | ||
config = [{'directory': image_file, | ||
'width': width, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E127 continuation line over-indented for visual indent'
PycodestyleBear (E127), severity NORMAL, section autopep8
.
bears/general/ImageDimensionBear.py
Outdated
|
||
with open('img_config.yml', 'w') as yaml_file: | ||
config = [{'directory': image_file, | ||
'width': width, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code does not comply to PEP8.
PEP8Bear, severity NORMAL, section autopep8
.
The issue can be fixed by applying the following patch:
--- a/bears/general/ImageDimensionBear.py
+++ b/bears/general/ImageDimensionBear.py
@@ -30,8 +30,8 @@
with open('img_config.yml', 'w') as yaml_file:
config = [{'directory': image_file,
- 'width': width,
- 'height': height}]
+ 'width': width,
+ 'height': height}]
yaml.dump(config, yaml_file, default_flow_style=False)
cmd = 'img_checker'
output = run(cmd, stdout=Capture(), stderr=Capture())
e94a8ad
to
7e42486
Compare
shutil.which = lambda *args, **kwargs: 'path/to/git' | ||
self.assertTrue(ImageDimensionBear.check_prerequisites()) | ||
finally: | ||
shutil.which = _shutil_which |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
W291 trailing whitespace'
PycodestyleBear (W291), severity NORMAL, section autopep8
.
shutil.which = lambda *args, **kwargs: 'path/to/git' | ||
self.assertTrue(ImageDimensionBear.check_prerequisites()) | ||
finally: | ||
shutil.which = _shutil_which |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code does not comply to PEP8.
PEP8Bear, severity NORMAL, section autopep8
.
The issue can be fixed by applying the following patch:
--- a/tests/general/ImageDimensionBearTest.py
+++ b/tests/general/ImageDimensionBearTest.py
@@ -27,7 +27,7 @@
shutil.which = lambda *args, **kwargs: 'path/to/git'
self.assertTrue(ImageDimensionBear.check_prerequisites())
finally:
- shutil.which = _shutil_which
+ shutil.which = _shutil_which
def test_run_with_png(self):
message = "message='The image ./test-img/img.png is larger"
shutil.which = lambda *args, **kwargs: 'path/to/git' | ||
self.assertTrue(ImageDimensionBear.check_prerequisites()) | ||
finally: | ||
shutil.which = _shutil_which |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line contains following spacing inconsistencies:
- Trailing whitespaces.
SpaceConsistencyBear, severity NORMAL, section python
.
The issue can be fixed by applying the following patch:
--- a/tests/general/ImageDimensionBearTest.py
+++ b/tests/general/ImageDimensionBearTest.py
@@ -27,7 +27,7 @@
shutil.which = lambda *args, **kwargs: 'path/to/git'
self.assertTrue(ImageDimensionBear.check_prerequisites())
finally:
- shutil.which = _shutil_which
+ shutil.which = _shutil_which
def test_run_with_png(self):
message = "message='The image ./test-img/img.png is larger"
7e42486
to
06c6fc5
Compare
@sils @jayvdb all test except the appveyor one (test in windows) didn't pass. my guess is that this is happening because of the space that was missing in GemRequirement in dependency_management, but the fix is done and the PR was merged https://gitlab.com/coala/package_manager/merge_requests/10/diffs . now it only needs to have a release. I hope that will have that test pass as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not document it as well?
the documentation goes to bear-docs right? or did you mean to document in the code, how other bears had for params and returns? @robbyoconnor , if its to document code ok I am doing it now, and if its the first one, can I do it once this PR gets merged? since more changes might be requrested it gets merged. |
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
4 similar comments
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
3 similar comments
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
coala/coala#3560 is merged. This bear can now proceed. |
Please make sure the images used for testing aren't copyrighted. I recommend creating your own images, I think a blank image is enough for this bear. |
5a06853
to
8fa3242
Compare
import shutil | ||
|
||
from bears.general.ImageDimensionBear import * | ||
from coalib.output.printers.LOG_LEVEL import LOG_LEVEL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file contains unused source code.
PyUnusedCodeBear, severity NORMAL, section flakes
.
The issue can be fixed by applying the following patch:
--- a/tests/general/ImageDimensionBearTest.py
+++ b/tests/general/ImageDimensionBearTest.py
@@ -4,9 +4,7 @@
import shutil
from bears.general.ImageDimensionBear import *
-from coalib.output.printers.LOG_LEVEL import LOG_LEVEL
from coalib.settings.Section import Section
-from coalib.settings.Setting import Setting
from coalib.testing.BearTestHelper import generate_skip_decorator
@@ -0,0 +1,91 @@ | |||
import unittest | |||
from unittest.case import skip, skipIf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file contains unused source code.
PyUnusedCodeBear, severity NORMAL, section flakes
.
The issue can be fixed by applying the following patch:
--- a/tests/general/ImageDimensionBearTest.py
+++ b/tests/general/ImageDimensionBearTest.py
@@ -1,5 +1,4 @@
import unittest
-from unittest.case import skip, skipIf
from queue import Queue
import shutil
192e032
to
a7bf6c3
Compare
Added ImageDimensionBear.py in bears/general, that runs the gem img_checker to check if images follow given dimensions by the user. Also added unittest for the bear, ImageDimensionBearTest.py in tests/general Closes coala#1260
a7bf6c3
to
3123b7f
Compare
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
2 similar comments
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
2 similar comments
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
Closes #1260
I have made the bear and written unittest for the bear as well. I am doing this PR to confirm what I have done till now is fine.
Another reason for making this WIP is because I still have to handle files for the bear. This is a GlobalBear and doesnt need any file, however I am unable to run the bear without a file. Presently .coafile has to look something like this to run ImageDimensionBear:
now here I think
files
is unnecessary and want to remove this but not sure how to.Herer's how the it looks when I run the bear: http://pastebin.com/UebXyuiE
& the Test: