Giter Site home page Giter Site logo

django-lint's Introduction

django-lint

Important notice

This project has been 2008 and was maintained until 2011; it has since been deprecated. If you wish to check out similar functionality, please see:

Ideas

General

  • Default manager with restrictive get_query_set()

  • Oldforms (?)

  • Overriding definition of model. e.g.:

    class MyModel(models.Model):

    : foo = [..]

    foo = [..]

  • Not importing settings via "django.conf import settings"

  • Not using reverse (or @permalink) in get_absolute_url (?)

  • Form definitions in models.py

  • Ignore tests

Models

  • Don't count ManyToMany fields on a model as a field

Remove common prefix checking. models.. specifying "objects = " should be last

Views

  • Calling request.is_authenticated without actually calling
function
  • order_by('?')
  • request.method.upper is a no-op (etc.)
  • cache.set without a timeout

URLS

  • Unreversible urlpatterns

Layout

  • Form class not in forms.py
  • Admin class not in admin.py

Templates

  • {% if foo %}{{ foo }}{% else %}bar{% endif %} => {{ foo|default:"bar" }}
  • {% with foo as bar %} ... [ not using {{ bar }} ] ... {% endwith %}
  • {% endblock %} vs. {% endblock blockname %}

Settings

  • Ordering of MIDDLEWARE_CLASSES
  • TEMPLATE_DIRS not absolute

Layout

  • forms not in forms.py managers not in managers.py

django-lint's People

Contributors

fabiocorneti avatar gbin avatar lamby avatar mattdennewitz avatar patrys avatar petrdlouhy 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

django-lint's Issues

application's settings.py file problem

Each application of the project can contain local settings.py file, which are not django settings. For these files django-lint.py shows error:

W:  1,0: Missing required field 'MANAGERS'
W:  1,0: Missing required field 'ADMINS'
W:  1,0: Missing required field 'TEMPLATE_DEBUG'
W:  1,0: Missing required field 'MIDDLEWARE_CLASSES'
W:  1,0: Missing required field 'DEBUG'
W:  1,0: Missing required field 'INSTALLED_APPS'

AttributeError: 'Assign' object has no attribute 'getChildNodes'

File "/home/kmmbvnr/Projects/wthr.cc/mobistyle/env/local/lib/python2.7/site-packages/DjangoLint/AstCheckers/model_fields.py", line 100, in visit_callfunc
x = node.parent.getChildNodes()[0]
AttributeError: 'Assign' object has no attribute 'getChildNodes'

And here is the file content:

from django.db import models

class TheModel(models.Model):
slug = models.SlugField(primary_key=True)

Running django-lint programmatically

Would it be possible to refactor script.py to copy the same interface pylint is using? It's possible to run it programmatically as:

from pylint.lint import run
Run(['--errors-only', 'myfile.py', ...])

which would be pretty handy in DjangoLint as well.

TypeError: '_Yes' object is not iterable

I cloned https://github.com/mollyproject/mollyproject.git

cd to mollyproject/molly/apps/home
and run django-lint views.py

returns

[mrunge@mrungexp home]$ django-lint views.py
Traceback (most recent call last):
File "/usr/bin/django-lint", line 25, in
sys.exit(script.main())
File "/usr/lib/python2.7/site-packages/DjangoLint/script.py", line 120, in main
linter.check([target])
File "/usr/lib/python2.7/site-packages/pylint/lint.py", line 489, in check
self.check_astng_module(astng, walker, rawcheckers)
File "/usr/lib/python2.7/site-packages/pylint/lint.py", line 563, in check_astng_module
walker.walk(astng)
File "/usr/lib/python2.7/site-packages/pylint/utils.py", line 520, in walk
self.walk(child)
File "/usr/lib/python2.7/site-packages/pylint/utils.py", line 517, in walk
cb(astng)
File "/usr/lib/python2.7/site-packages/DjangoLint/AstCheckers/model_methods.py", line 117, in visit_class
if not is_model(node):
File "/usr/lib/python2.7/site-packages/DjangoLint/AstCheckers/utils.py", line 40, in is_model
for node in nodes:
TypeError: '_Yes' object is not iterable

version conflict with logilab.common

I get this exception while trying django-lint:

$ django-lint .
Traceback (most recent call last):
  File "../../venv/bin/django-lint", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/venv/local/lib/python2.7/site-packages/pkg_resources.py", line 2829, in <module>
    working_set = WorkingSet._build_master()
  File "/venv/local/lib/python2.7/site-packages/pkg_resources.py", line 451, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/venv/local/lib/python2.7/site-packages/pkg_resources.py", line 464, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/venv/local/lib/python2.7/site-packages/pkg_resources.py", line 643, in resolve
    raise VersionConflict(dist, req) # XXX put more info here
pkg_resources.VersionConflict: (logilab-common 1.0.2 (/venv/lib/python2.7/site-packages), Requirement.parse('logilab-common<=0.63.0'))

pylint works fine though. grepping 63 in django-lint returns nothing but in logilab common finds:

./common/testlib.py:is_generator = deprecated('[lgc 0.63] use inspect.isgeneratorfunction')(isgeneratorfunction)
./common/pytest.py:    @deprecated('[lgc 0.63.1] Use the pause_trace() context manager')
./common/pytest.py:    @deprecated('[lgc 0.63.1] Use the pause_trace() context manager')

But i don't see any of these referenced in django-lint.

Extract of pip freeze:

django-lint==2.0.1
dodgy==0.1.7
flake8==2.4.1
line-profiler==1.0
logilab-common==1.0.2
mccabe==0.3.1
pep257==0.7.0
pep8==1.6.2
pep8-naming==0.3.3
pilkit==1.1.6
prospector==0.10.2
pyflakes==0.8.1
pylint==1.4.4
pylint-celery==0.3
pylint-common==0.2.1
pylint-django==0.6.1
pylint-plugin-utils==0.2.3

valid pylint options confuse django-lint

I've got this in my manage.py to disable some pylint checks:

#!/usr/bin/python
from django.core.management import execute_manager
try:
    # pylint: disable=W0403,F0401
    import settings # Assumed to be in the same directory.

and when I run django-lint, I get errors like these:

************* Module libravatar.manage
E:  4: Bad option value 'W0403'
E:  4: Bad option value 'F0401'

Could it be that django-lint has problems recognizing valid pylint options?

Add support for versions of django

I would love to be able to state what version of django i've written in and be able to lint to the best practices for that particular version of django

Error when running: No module named 'size'

Any ideas?

$ django-lint .
Traceback (most recent call last):
  File "/user/ubuntu/virtualenv/bin/django-lint", line 11, in <module>
    sys.exit(main())
  File "/user/ubuntu/virtualenv/lib/python3.4/site-packages/DjangoLint/script.py", line 133, in main
    AstCheckers.register(linter)
  File "/user/ubuntu/virtualenv/lib/python3.4/site-packages/DjangoLint/AstCheckers/__init__.py", line 22, in register
    from size import SizeChecker
ImportError: No module named 'size'

pylint >= 1.0 breaks django-lint

django-lint installs pylint 1.5.2 with pip, but is not compatible with pylint >= 1.0.

I have quick fixed the issue by installing pylint<1.0, I don't know if this is the best practice.

How to tell django-lint not to check a model?

I have a model that must be without any field (it is an abstract model).
Everytime I lint my project I receive the message:

W: 13,0:MyCustomModel: Model has no fields

How can I tell django-lint not to check MyCustomModel?

Show 'redefinition of function' when using property.setter

When in my code I have:

class Bar(object):
    @property
    def foo(self):
        return self._foo

    @foo.setter
    def foo(self, value):
        self._foo = value

This is absolutely valid python code but django lint tells me:

bar.py.XX: redefinition of function 'foo' from line XX

The info of django lint tells 'Django Lint is a wrapper around PyLint', but when I test this with pylint there is NO error like E:XXX,XX:Bar.foo: method already defined line XX

TypeError: %d format: a number is required, not _Yes

Hello,

Here's what I get when using django-lint on Ubuntu 10.10 installed either from package or from git-cloned code:

Traceback (most recent call last):
File "./django-lint", line 25, in
sys.exit(script.main())
File "/home/kostik/distr/django-lint/DjangoLint/script.py", line 139, in main
linter.check([target])
File "/usr/lib/pymodules/python2.6/pylint/lint.py", line 488, in check
self.check_astng_module(astng, walker, rawcheckers)
File "/usr/lib/pymodules/python2.6/pylint/lint.py", line 563, in check_astng_module
walker.walk(astng)
File "/usr/lib/pymodules/python2.6/pylint/utils.py", line 516, in walk
self.walk(child)
File "/usr/lib/pymodules/python2.6/pylint/utils.py", line 516, in walk
self.walk(child)
File "/usr/lib/pymodules/python2.6/pylint/utils.py", line 516, in walk
self.walk(child)
File "/usr/lib/pymodules/python2.6/pylint/utils.py", line 513, in walk
cb(astng)
File "/home/kostik/distr/django-lint/DjangoLint/AstCheckers/model_fields.py", line 154, in visit_callfunc
self.config.max_charfield_length,
File "/usr/lib/pymodules/python2.6/pylint/checkers/init.py", line 92, in add_message
self.linter.add_message(msg_id, line, node, args)
File "/usr/lib/pymodules/python2.6/pylint/utils.py", line 265, in add_message
msg %= args
TypeError: %d format: a number is required, not _Yes

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.