├── .gitignore
├── COPYING
├── DjangoLint
├── AstCheckers
│ ├── __init__.py
│ ├── admin.py
│ ├── model_fields.py
│ ├── model_methods.py
│ ├── settings.py
│ ├── size.py
│ └── utils.py
├── __init__.py
└── script.py
├── README.md
├── django-lint
├── django-lint.1
├── django_lint_example
├── __init__.py
├── example
│ ├── __init__.py
│ ├── models
│ │ └── __init__.py
│ └── views.py
├── manage.py
├── settings.py
└── urls.py
└── setup.py
/.gitignore:
--------------------------------------------------------------------------------
1 | *.pyc
2 | *.egg-info
3 | /build
4 | /dist
5 |
--------------------------------------------------------------------------------
/COPYING:
--------------------------------------------------------------------------------
1 |
2 | GNU GENERAL PUBLIC LICENSE
3 | Version 3, 29 June 2007
4 |
5 | Copyright (C) 2007 Free Software Foundation, Inc.
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The GNU General Public License is a free, copyleft license for
12 | software and other kinds of works.
13 |
14 | The licenses for most software and other practical works are designed
15 | to take away your freedom to share and change the works. By contrast,
16 | the GNU General Public License is intended to guarantee your freedom to
17 | share and change all versions of a program--to make sure it remains free
18 | software for all its users. We, the Free Software Foundation, use the
19 | GNU General Public License for most of our software; it applies also to
20 | any other work released this way by its authors. You can apply it to
21 | your programs, too.
22 |
23 | When we speak of free software, we are referring to freedom, not
24 | price. Our General Public Licenses are designed to make sure that you
25 | have the freedom to distribute copies of free software (and charge for
26 | them if you wish), that you receive source code or can get it if you
27 | want it, that you can change the software or use pieces of it in new
28 | free programs, and that you know you can do these things.
29 |
30 | To protect your rights, we need to prevent others from denying you
31 | these rights or asking you to surrender the rights. Therefore, you have
32 | certain responsibilities if you distribute copies of the software, or if
33 | you modify it: responsibilities to respect the freedom of others.
34 |
35 | For example, if you distribute copies of such a program, whether
36 | gratis or for a fee, you must pass on to the recipients the same
37 | freedoms that you received. You must make sure that they, too, receive
38 | or can get the source code. And you must show them these terms so they
39 | know their rights.
40 |
41 | Developers that use the GNU GPL protect your rights with two steps:
42 | (1) assert copyright on the software, and (2) offer you this License
43 | giving you legal permission to copy, distribute and/or modify it.
44 |
45 | For the developers' and authors' protection, the GPL clearly explains
46 | that there is no warranty for this free software. For both users' and
47 | authors' sake, the GPL requires that modified versions be marked as
48 | changed, so that their problems will not be attributed erroneously to
49 | authors of previous versions.
50 |
51 | Some devices are designed to deny users access to install or run
52 | modified versions of the software inside them, although the manufacturer
53 | can do so. This is fundamentally incompatible with the aim of
54 | protecting users' freedom to change the software. The systematic
55 | pattern of such abuse occurs in the area of products for individuals to
56 | use, which is precisely where it is most unacceptable. Therefore, we
57 | have designed this version of the GPL to prohibit the practice for those
58 | products. If such problems arise substantially in other domains, we
59 | stand ready to extend this provision to those domains in future versions
60 | of the GPL, as needed to protect the freedom of users.
61 |
62 | Finally, every program is threatened constantly by software patents.
63 | States should not allow patents to restrict development and use of
64 | software on general-purpose computers, but in those that do, we wish to
65 | avoid the special danger that patents applied to a free program could
66 | make it effectively proprietary. To prevent this, the GPL assures that
67 | patents cannot be used to render the program non-free.
68 |
69 | The precise terms and conditions for copying, distribution and
70 | modification follow.
71 |
72 | TERMS AND CONDITIONS
73 |
74 | 0. Definitions.
75 |
76 | "This License" refers to version 3 of the GNU General Public License.
77 |
78 | "Copyright" also means copyright-like laws that apply to other kinds of
79 | works, such as semiconductor masks.
80 |
81 | "The Program" refers to any copyrightable work licensed under this
82 | License. Each licensee is addressed as "you". "Licensees" and
83 | "recipients" may be individuals or organizations.
84 |
85 | To "modify" a work means to copy from or adapt all or part of the work
86 | in a fashion requiring copyright permission, other than the making of an
87 | exact copy. The resulting work is called a "modified version" of the
88 | earlier work or a work "based on" the earlier work.
89 |
90 | A "covered work" means either the unmodified Program or a work based
91 | on the Program.
92 |
93 | To "propagate" a work means to do anything with it that, without
94 | permission, would make you directly or secondarily liable for
95 | infringement under applicable copyright law, except executing it on a
96 | computer or modifying a private copy. Propagation includes copying,
97 | distribution (with or without modification), making available to the
98 | public, and in some countries other activities as well.
99 |
100 | To "convey" a work means any kind of propagation that enables other
101 | parties to make or receive copies. Mere interaction with a user through
102 | a computer network, with no transfer of a copy, is not conveying.
103 |
104 | An interactive user interface displays "Appropriate Legal Notices"
105 | to the extent that it includes a convenient and prominently visible
106 | feature that (1) displays an appropriate copyright notice, and (2)
107 | tells the user that there is no warranty for the work (except to the
108 | extent that warranties are provided), that licensees may convey the
109 | work under this License, and how to view a copy of this License. If
110 | the interface presents a list of user commands or options, such as a
111 | menu, a prominent item in the list meets this criterion.
112 |
113 | 1. Source Code.
114 |
115 | The "source code" for a work means the preferred form of the work
116 | for making modifications to it. "Object code" means any non-source
117 | form of a work.
118 |
119 | A "Standard Interface" means an interface that either is an official
120 | standard defined by a recognized standards body, or, in the case of
121 | interfaces specified for a particular programming language, one that
122 | is widely used among developers working in that language.
123 |
124 | The "System Libraries" of an executable work include anything, other
125 | than the work as a whole, that (a) is included in the normal form of
126 | packaging a Major Component, but which is not part of that Major
127 | Component, and (b) serves only to enable use of the work with that
128 | Major Component, or to implement a Standard Interface for which an
129 | implementation is available to the public in source code form. A
130 | "Major Component", in this context, means a major essential component
131 | (kernel, window system, and so on) of the specific operating system
132 | (if any) on which the executable work runs, or a compiler used to
133 | produce the work, or an object code interpreter used to run it.
134 |
135 | The "Corresponding Source" for a work in object code form means all
136 | the source code needed to generate, install, and (for an executable
137 | work) run the object code and to modify the work, including scripts to
138 | control those activities. However, it does not include the work's
139 | System Libraries, or general-purpose tools or generally available free
140 | programs which are used unmodified in performing those activities but
141 | which are not part of the work. For example, Corresponding Source
142 | includes interface definition files associated with source files for
143 | the work, and the source code for shared libraries and dynamically
144 | linked subprograms that the work is specifically designed to require,
145 | such as by intimate data communication or control flow between those
146 | subprograms and other parts of the work.
147 |
148 | The Corresponding Source need not include anything that users
149 | can regenerate automatically from other parts of the Corresponding
150 | Source.
151 |
152 | The Corresponding Source for a work in source code form is that
153 | same work.
154 |
155 | 2. Basic Permissions.
156 |
157 | All rights granted under this License are granted for the term of
158 | copyright on the Program, and are irrevocable provided the stated
159 | conditions are met. This License explicitly affirms your unlimited
160 | permission to run the unmodified Program. The output from running a
161 | covered work is covered by this License only if the output, given its
162 | content, constitutes a covered work. This License acknowledges your
163 | rights of fair use or other equivalent, as provided by copyright law.
164 |
165 | You may make, run and propagate covered works that you do not
166 | convey, without conditions so long as your license otherwise remains
167 | in force. You may convey covered works to others for the sole purpose
168 | of having them make modifications exclusively for you, or provide you
169 | with facilities for running those works, provided that you comply with
170 | the terms of this License in conveying all material for which you do
171 | not control copyright. Those thus making or running the covered works
172 | for you must do so exclusively on your behalf, under your direction
173 | and control, on terms that prohibit them from making any copies of
174 | your copyrighted material outside their relationship with you.
175 |
176 | Conveying under any other circumstances is permitted solely under
177 | the conditions stated below. Sublicensing is not allowed; section 10
178 | makes it unnecessary.
179 |
180 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
181 |
182 | No covered work shall be deemed part of an effective technological
183 | measure under any applicable law fulfilling obligations under article
184 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
185 | similar laws prohibiting or restricting circumvention of such
186 | measures.
187 |
188 | When you convey a covered work, you waive any legal power to forbid
189 | circumvention of technological measures to the extent such circumvention
190 | is effected by exercising rights under this License with respect to
191 | the covered work, and you disclaim any intention to limit operation or
192 | modification of the work as a means of enforcing, against the work's
193 | users, your or third parties' legal rights to forbid circumvention of
194 | technological measures.
195 |
196 | 4. Conveying Verbatim Copies.
197 |
198 | You may convey verbatim copies of the Program's source code as you
199 | receive it, in any medium, provided that you conspicuously and
200 | appropriately publish on each copy an appropriate copyright notice;
201 | keep intact all notices stating that this License and any
202 | non-permissive terms added in accord with section 7 apply to the code;
203 | keep intact all notices of the absence of any warranty; and give all
204 | recipients a copy of this License along with the Program.
205 |
206 | You may charge any price or no price for each copy that you convey,
207 | and you may offer support or warranty protection for a fee.
208 |
209 | 5. Conveying Modified Source Versions.
210 |
211 | You may convey a work based on the Program, or the modifications to
212 | produce it from the Program, in the form of source code under the
213 | terms of section 4, provided that you also meet all of these conditions:
214 |
215 | a) The work must carry prominent notices stating that you modified
216 | it, and giving a relevant date.
217 |
218 | b) The work must carry prominent notices stating that it is
219 | released under this License and any conditions added under section
220 | 7. This requirement modifies the requirement in section 4 to
221 | "keep intact all notices".
222 |
223 | c) You must license the entire work, as a whole, under this
224 | License to anyone who comes into possession of a copy. This
225 | License will therefore apply, along with any applicable section 7
226 | additional terms, to the whole of the work, and all its parts,
227 | regardless of how they are packaged. This License gives no
228 | permission to license the work in any other way, but it does not
229 | invalidate such permission if you have separately received it.
230 |
231 | d) If the work has interactive user interfaces, each must display
232 | Appropriate Legal Notices; however, if the Program has interactive
233 | interfaces that do not display Appropriate Legal Notices, your
234 | work need not make them do so.
235 |
236 | A compilation of a covered work with other separate and independent
237 | works, which are not by their nature extensions of the covered work,
238 | and which are not combined with it such as to form a larger program,
239 | in or on a volume of a storage or distribution medium, is called an
240 | "aggregate" if the compilation and its resulting copyright are not
241 | used to limit the access or legal rights of the compilation's users
242 | beyond what the individual works permit. Inclusion of a covered work
243 | in an aggregate does not cause this License to apply to the other
244 | parts of the aggregate.
245 |
246 | 6. Conveying Non-Source Forms.
247 |
248 | You may convey a covered work in object code form under the terms
249 | of sections 4 and 5, provided that you also convey the
250 | machine-readable Corresponding Source under the terms of this License,
251 | in one of these ways:
252 |
253 | a) Convey the object code in, or embodied in, a physical product
254 | (including a physical distribution medium), accompanied by the
255 | Corresponding Source fixed on a durable physical medium
256 | customarily used for software interchange.
257 |
258 | b) Convey the object code in, or embodied in, a physical product
259 | (including a physical distribution medium), accompanied by a
260 | written offer, valid for at least three years and valid for as
261 | long as you offer spare parts or customer support for that product
262 | model, to give anyone who possesses the object code either (1) a
263 | copy of the Corresponding Source for all the software in the
264 | product that is covered by this License, on a durable physical
265 | medium customarily used for software interchange, for a price no
266 | more than your reasonable cost of physically performing this
267 | conveying of source, or (2) access to copy the
268 | Corresponding Source from a network server at no charge.
269 |
270 | c) Convey individual copies of the object code with a copy of the
271 | written offer to provide the Corresponding Source. This
272 | alternative is allowed only occasionally and noncommercially, and
273 | only if you received the object code with such an offer, in accord
274 | with subsection 6b.
275 |
276 | d) Convey the object code by offering access from a designated
277 | place (gratis or for a charge), and offer equivalent access to the
278 | Corresponding Source in the same way through the same place at no
279 | further charge. You need not require recipients to copy the
280 | Corresponding Source along with the object code. If the place to
281 | copy the object code is a network server, the Corresponding Source
282 | may be on a different server (operated by you or a third party)
283 | that supports equivalent copying facilities, provided you maintain
284 | clear directions next to the object code saying where to find the
285 | Corresponding Source. Regardless of what server hosts the
286 | Corresponding Source, you remain obligated to ensure that it is
287 | available for as long as needed to satisfy these requirements.
288 |
289 | e) Convey the object code using peer-to-peer transmission, provided
290 | you inform other peers where the object code and Corresponding
291 | Source of the work are being offered to the general public at no
292 | charge under subsection 6d.
293 |
294 | A separable portion of the object code, whose source code is excluded
295 | from the Corresponding Source as a System Library, need not be
296 | included in conveying the object code work.
297 |
298 | A "User Product" is either (1) a "consumer product", which means any
299 | tangible personal property which is normally used for personal, family,
300 | or household purposes, or (2) anything designed or sold for incorporation
301 | into a dwelling. In determining whether a product is a consumer product,
302 | doubtful cases shall be resolved in favor of coverage. For a particular
303 | product received by a particular user, "normally used" refers to a
304 | typical or common use of that class of product, regardless of the status
305 | of the particular user or of the way in which the particular user
306 | actually uses, or expects or is expected to use, the product. A product
307 | is a consumer product regardless of whether the product has substantial
308 | commercial, industrial or non-consumer uses, unless such uses represent
309 | the only significant mode of use of the product.
310 |
311 | "Installation Information" for a User Product means any methods,
312 | procedures, authorization keys, or other information required to install
313 | and execute modified versions of a covered work in that User Product from
314 | a modified version of its Corresponding Source. The information must
315 | suffice to ensure that the continued functioning of the modified object
316 | code is in no case prevented or interfered with solely because
317 | modification has been made.
318 |
319 | If you convey an object code work under this section in, or with, or
320 | specifically for use in, a User Product, and the conveying occurs as
321 | part of a transaction in which the right of possession and use of the
322 | User Product is transferred to the recipient in perpetuity or for a
323 | fixed term (regardless of how the transaction is characterized), the
324 | Corresponding Source conveyed under this section must be accompanied
325 | by the Installation Information. But this requirement does not apply
326 | if neither you nor any third party retains the ability to install
327 | modified object code on the User Product (for example, the work has
328 | been installed in ROM).
329 |
330 | The requirement to provide Installation Information does not include a
331 | requirement to continue to provide support service, warranty, or updates
332 | for a work that has been modified or installed by the recipient, or for
333 | the User Product in which it has been modified or installed. Access to a
334 | network may be denied when the modification itself materially and
335 | adversely affects the operation of the network or violates the rules and
336 | protocols for communication across the network.
337 |
338 | Corresponding Source conveyed, and Installation Information provided,
339 | in accord with this section must be in a format that is publicly
340 | documented (and with an implementation available to the public in
341 | source code form), and must require no special password or key for
342 | unpacking, reading or copying.
343 |
344 | 7. Additional Terms.
345 |
346 | "Additional permissions" are terms that supplement the terms of this
347 | License by making exceptions from one or more of its conditions.
348 | Additional permissions that are applicable to the entire Program shall
349 | be treated as though they were included in this License, to the extent
350 | that they are valid under applicable law. If additional permissions
351 | apply only to part of the Program, that part may be used separately
352 | under those permissions, but the entire Program remains governed by
353 | this License without regard to the additional permissions.
354 |
355 | When you convey a copy of a covered work, you may at your option
356 | remove any additional permissions from that copy, or from any part of
357 | it. (Additional permissions may be written to require their own
358 | removal in certain cases when you modify the work.) You may place
359 | additional permissions on material, added by you to a covered work,
360 | for which you have or can give appropriate copyright permission.
361 |
362 | Notwithstanding any other provision of this License, for material you
363 | add to a covered work, you may (if authorized by the copyright holders of
364 | that material) supplement the terms of this License with terms:
365 |
366 | a) Disclaiming warranty or limiting liability differently from the
367 | terms of sections 15 and 16 of this License; or
368 |
369 | b) Requiring preservation of specified reasonable legal notices or
370 | author attributions in that material or in the Appropriate Legal
371 | Notices displayed by works containing it; or
372 |
373 | c) Prohibiting misrepresentation of the origin of that material, or
374 | requiring that modified versions of such material be marked in
375 | reasonable ways as different from the original version; or
376 |
377 | d) Limiting the use for publicity purposes of names of licensors or
378 | authors of the material; or
379 |
380 | e) Declining to grant rights under trademark law for use of some
381 | trade names, trademarks, or service marks; or
382 |
383 | f) Requiring indemnification of licensors and authors of that
384 | material by anyone who conveys the material (or modified versions of
385 | it) with contractual assumptions of liability to the recipient, for
386 | any liability that these contractual assumptions directly impose on
387 | those licensors and authors.
388 |
389 | All other non-permissive additional terms are considered "further
390 | restrictions" within the meaning of section 10. If the Program as you
391 | received it, or any part of it, contains a notice stating that it is
392 | governed by this License along with a term that is a further
393 | restriction, you may remove that term. If a license document contains
394 | a further restriction but permits relicensing or conveying under this
395 | License, you may add to a covered work material governed by the terms
396 | of that license document, provided that the further restriction does
397 | not survive such relicensing or conveying.
398 |
399 | If you add terms to a covered work in accord with this section, you
400 | must place, in the relevant source files, a statement of the
401 | additional terms that apply to those files, or a notice indicating
402 | where to find the applicable terms.
403 |
404 | Additional terms, permissive or non-permissive, may be stated in the
405 | form of a separately written license, or stated as exceptions;
406 | the above requirements apply either way.
407 |
408 | 8. Termination.
409 |
410 | You may not propagate or modify a covered work except as expressly
411 | provided under this License. Any attempt otherwise to propagate or
412 | modify it is void, and will automatically terminate your rights under
413 | this License (including any patent licenses granted under the third
414 | paragraph of section 11).
415 |
416 | However, if you cease all violation of this License, then your
417 | license from a particular copyright holder is reinstated (a)
418 | provisionally, unless and until the copyright holder explicitly and
419 | finally terminates your license, and (b) permanently, if the copyright
420 | holder fails to notify you of the violation by some reasonable means
421 | prior to 60 days after the cessation.
422 |
423 | Moreover, your license from a particular copyright holder is
424 | reinstated permanently if the copyright holder notifies you of the
425 | violation by some reasonable means, this is the first time you have
426 | received notice of violation of this License (for any work) from that
427 | copyright holder, and you cure the violation prior to 30 days after
428 | your receipt of the notice.
429 |
430 | Termination of your rights under this section does not terminate the
431 | licenses of parties who have received copies or rights from you under
432 | this License. If your rights have been terminated and not permanently
433 | reinstated, you do not qualify to receive new licenses for the same
434 | material under section 10.
435 |
436 | 9. Acceptance Not Required for Having Copies.
437 |
438 | You are not required to accept this License in order to receive or
439 | run a copy of the Program. Ancillary propagation of a covered work
440 | occurring solely as a consequence of using peer-to-peer transmission
441 | to receive a copy likewise does not require acceptance. However,
442 | nothing other than this License grants you permission to propagate or
443 | modify any covered work. These actions infringe copyright if you do
444 | not accept this License. Therefore, by modifying or propagating a
445 | covered work, you indicate your acceptance of this License to do so.
446 |
447 | 10. Automatic Licensing of Downstream Recipients.
448 |
449 | Each time you convey a covered work, the recipient automatically
450 | receives a license from the original licensors, to run, modify and
451 | propagate that work, subject to this License. You are not responsible
452 | for enforcing compliance by third parties with this License.
453 |
454 | An "entity transaction" is a transaction transferring control of an
455 | organization, or substantially all assets of one, or subdividing an
456 | organization, or merging organizations. If propagation of a covered
457 | work results from an entity transaction, each party to that
458 | transaction who receives a copy of the work also receives whatever
459 | licenses to the work the party's predecessor in interest had or could
460 | give under the previous paragraph, plus a right to possession of the
461 | Corresponding Source of the work from the predecessor in interest, if
462 | the predecessor has it or can get it with reasonable efforts.
463 |
464 | You may not impose any further restrictions on the exercise of the
465 | rights granted or affirmed under this License. For example, you may
466 | not impose a license fee, royalty, or other charge for exercise of
467 | rights granted under this License, and you may not initiate litigation
468 | (including a cross-claim or counterclaim in a lawsuit) alleging that
469 | any patent claim is infringed by making, using, selling, offering for
470 | sale, or importing the Program or any portion of it.
471 |
472 | 11. Patents.
473 |
474 | A "contributor" is a copyright holder who authorizes use under this
475 | License of the Program or a work on which the Program is based. The
476 | work thus licensed is called the contributor's "contributor version".
477 |
478 | A contributor's "essential patent claims" are all patent claims
479 | owned or controlled by the contributor, whether already acquired or
480 | hereafter acquired, that would be infringed by some manner, permitted
481 | by this License, of making, using, or selling its contributor version,
482 | but do not include claims that would be infringed only as a
483 | consequence of further modification of the contributor version. For
484 | purposes of this definition, "control" includes the right to grant
485 | patent sublicenses in a manner consistent with the requirements of
486 | this License.
487 |
488 | Each contributor grants you a non-exclusive, worldwide, royalty-free
489 | patent license under the contributor's essential patent claims, to
490 | make, use, sell, offer for sale, import and otherwise run, modify and
491 | propagate the contents of its contributor version.
492 |
493 | In the following three paragraphs, a "patent license" is any express
494 | agreement or commitment, however denominated, not to enforce a patent
495 | (such as an express permission to practice a patent or covenant not to
496 | sue for patent infringement). To "grant" such a patent license to a
497 | party means to make such an agreement or commitment not to enforce a
498 | patent against the party.
499 |
500 | If you convey a covered work, knowingly relying on a patent license,
501 | and the Corresponding Source of the work is not available for anyone
502 | to copy, free of charge and under the terms of this License, through a
503 | publicly available network server or other readily accessible means,
504 | then you must either (1) cause the Corresponding Source to be so
505 | available, or (2) arrange to deprive yourself of the benefit of the
506 | patent license for this particular work, or (3) arrange, in a manner
507 | consistent with the requirements of this License, to extend the patent
508 | license to downstream recipients. "Knowingly relying" means you have
509 | actual knowledge that, but for the patent license, your conveying the
510 | covered work in a country, or your recipient's use of the covered work
511 | in a country, would infringe one or more identifiable patents in that
512 | country that you have reason to believe are valid.
513 |
514 | If, pursuant to or in connection with a single transaction or
515 | arrangement, you convey, or propagate by procuring conveyance of, a
516 | covered work, and grant a patent license to some of the parties
517 | receiving the covered work authorizing them to use, propagate, modify
518 | or convey a specific copy of the covered work, then the patent license
519 | you grant is automatically extended to all recipients of the covered
520 | work and works based on it.
521 |
522 | A patent license is "discriminatory" if it does not include within
523 | the scope of its coverage, prohibits the exercise of, or is
524 | conditioned on the non-exercise of one or more of the rights that are
525 | specifically granted under this License. You may not convey a covered
526 | work if you are a party to an arrangement with a third party that is
527 | in the business of distributing software, under which you make payment
528 | to the third party based on the extent of your activity of conveying
529 | the work, and under which the third party grants, to any of the
530 | parties who would receive the covered work from you, a discriminatory
531 | patent license (a) in connection with copies of the covered work
532 | conveyed by you (or copies made from those copies), or (b) primarily
533 | for and in connection with specific products or compilations that
534 | contain the covered work, unless you entered into that arrangement,
535 | or that patent license was granted, prior to 28 March 2007.
536 |
537 | Nothing in this License shall be construed as excluding or limiting
538 | any implied license or other defenses to infringement that may
539 | otherwise be available to you under applicable patent law.
540 |
541 | 12. No Surrender of Others' Freedom.
542 |
543 | If conditions are imposed on you (whether by court order, agreement or
544 | otherwise) that contradict the conditions of this License, they do not
545 | excuse you from the conditions of this License. If you cannot convey a
546 | covered work so as to satisfy simultaneously your obligations under this
547 | License and any other pertinent obligations, then as a consequence you may
548 | not convey it at all. For example, if you agree to terms that obligate you
549 | to collect a royalty for further conveying from those to whom you convey
550 | the Program, the only way you could satisfy both those terms and this
551 | License would be to refrain entirely from conveying the Program.
552 |
553 | 13. Use with the GNU Affero General Public License.
554 |
555 | Notwithstanding any other provision of this License, you have
556 | permission to link or combine any covered work with a work licensed
557 | under version 3 of the GNU Affero General Public License into a single
558 | combined work, and to convey the resulting work. The terms of this
559 | License will continue to apply to the part which is the covered work,
560 | but the special requirements of the GNU Affero General Public License,
561 | section 13, concerning interaction through a network will apply to the
562 | combination as such.
563 |
564 | 14. Revised Versions of this License.
565 |
566 | The Free Software Foundation may publish revised and/or new versions of
567 | the GNU General Public License from time to time. Such new versions will
568 | be similar in spirit to the present version, but may differ in detail to
569 | address new problems or concerns.
570 |
571 | Each version is given a distinguishing version number. If the
572 | Program specifies that a certain numbered version of the GNU General
573 | Public License "or any later version" applies to it, you have the
574 | option of following the terms and conditions either of that numbered
575 | version or of any later version published by the Free Software
576 | Foundation. If the Program does not specify a version number of the
577 | GNU General Public License, you may choose any version ever published
578 | by the Free Software Foundation.
579 |
580 | If the Program specifies that a proxy can decide which future
581 | versions of the GNU General Public License can be used, that proxy's
582 | public statement of acceptance of a version permanently authorizes you
583 | to choose that version for the Program.
584 |
585 | Later license versions may give you additional or different
586 | permissions. However, no additional obligations are imposed on any
587 | author or copyright holder as a result of your choosing to follow a
588 | later version.
589 |
590 | 15. Disclaimer of Warranty.
591 |
592 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
593 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
594 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
595 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
596 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
597 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
598 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
599 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
600 |
601 | 16. Limitation of Liability.
602 |
603 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
604 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
605 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
606 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
607 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
608 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
609 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
610 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
611 | SUCH DAMAGES.
612 |
613 | 17. Interpretation of Sections 15 and 16.
614 |
615 | If the disclaimer of warranty and limitation of liability provided
616 | above cannot be given local legal effect according to their terms,
617 | reviewing courts shall apply local law that most closely approximates
618 | an absolute waiver of all civil liability in connection with the
619 | Program, unless a warranty or assumption of liability accompanies a
620 | copy of the Program in return for a fee.
621 |
622 | END OF TERMS AND CONDITIONS
623 |
624 | How to Apply These Terms to Your New Programs
625 |
626 | If you develop a new program, and you want it to be of the greatest
627 | possible use to the public, the best way to achieve this is to make it
628 | free software which everyone can redistribute and change under these terms.
629 |
630 | To do so, attach the following notices to the program. It is safest
631 | to attach them to the start of each source file to most effectively
632 | state the exclusion of warranty; and each file should have at least
633 | the "copyright" line and a pointer to where the full notice is found.
634 |
635 |
636 | Copyright (C)
637 |
638 | This program is free software: you can redistribute it and/or modify
639 | it under the terms of the GNU General Public License as published by
640 | the Free Software Foundation, either version 3 of the License, or
641 | (at your option) any later version.
642 |
643 | This program is distributed in the hope that it will be useful,
644 | but WITHOUT ANY WARRANTY; without even the implied warranty of
645 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
646 | GNU General Public License for more details.
647 |
648 | You should have received a copy of the GNU General Public License
649 | along with this program. If not, see .
650 |
651 | Also add information on how to contact you by electronic and paper mail.
652 |
653 | If the program does terminal interaction, make it output a short
654 | notice like this when it starts in an interactive mode:
655 |
656 | Copyright (C)
657 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
658 | This is free software, and you are welcome to redistribute it
659 | under certain conditions; type `show c' for details.
660 |
661 | The hypothetical commands `show w' and `show c' should show the appropriate
662 | parts of the General Public License. Of course, your program's commands
663 | might be different; for a GUI interface, you would use an "about box".
664 |
665 | You should also get your employer (if you work as a programmer) or school,
666 | if any, to sign a "copyright disclaimer" for the program, if necessary.
667 | For more information on this, and how to apply and follow the GNU GPL, see
668 | .
669 |
670 | The GNU General Public License does not permit incorporating your program
671 | into proprietary programs. If your program is a subroutine library, you
672 | may consider it more useful to permit linking proprietary applications with
673 | the library. If this is what you want to do, use the GNU Lesser General
674 | Public License instead of this License. But first, please read
675 | .
676 |
677 |
--------------------------------------------------------------------------------
/DjangoLint/AstCheckers/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # django-lint -- Static analysis tool for Django projects and applications
4 | # Copyright (C) 2008-2009 Chris Lamb
5 | #
6 | # This program is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program. If not, see .
18 |
19 | __all__ = ('register',)
20 |
21 | def register(linter):
22 | from .size import SizeChecker
23 | from .admin import AdminChecker
24 | from .settings import SettingsChecker
25 | from .model_fields import ModelFieldsChecker
26 | from .model_methods import ModelMethodsChecker
27 |
28 | linter.register_checker(SizeChecker(linter))
29 | linter.register_checker(AdminChecker(linter))
30 | linter.register_checker(SettingsChecker(linter))
31 | linter.register_checker(ModelFieldsChecker(linter))
32 | linter.register_checker(ModelMethodsChecker(linter))
33 |
--------------------------------------------------------------------------------
/DjangoLint/AstCheckers/admin.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # django-lint -- Static analysis tool for Django projects and applications
4 | # Copyright (C) 2008-2009 Chris Lamb
5 | #
6 | # This program is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program. If not, see .
18 |
19 | from pylint.interfaces import IAstroidChecker
20 | from pylint.checkers import BaseChecker
21 |
22 | from .utils import nodeisinstance
23 |
24 | class AdminChecker(BaseChecker):
25 | __implements__ = IAstroidChecker
26 |
27 | name = 'django_admin'
28 | msgs = {
29 | 'W8020': (
30 | 'Not admin class',
31 | 'loldongs',
32 | 'Admin class %r not in admin.py',
33 | ),
34 | }
35 |
36 | ADMIN_BASE_CLASSES = (
37 | 'django.contrib.admin.options.ModelAdmin',
38 | )
39 |
40 | def visit_module(self, node):
41 | self.module = node
42 |
43 | def leave_class(self, node):
44 | if not nodeisinstance(node, self.ADMIN_BASE_CLASSES):
45 | return
46 |
47 | if not self.module.file.endswith('admin.py'):
48 | # Admin classes not in an app's admin.py can cause circular import
49 | # problems throughout a project.
50 | #
51 | # This is because registering an admin class implies a call to
52 | # models.get_apps() which attempts to import *every* models.py in
53 | # the project.
54 | #
55 | # Whilst your project should probably not have significant
56 | # inter-app dependencies, importing every possible models.py does
57 | # not help the situation and can cause ImportError when models are
58 | # loaded in different scenarios.
59 | self.add_message('W8020', node=node, args=(node.name,))
60 |
--------------------------------------------------------------------------------
/DjangoLint/AstCheckers/model_fields.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # django-lint -- Static analysis tool for Django projects and applications
4 | # Copyright (C) 2008-2009 Chris Lamb
5 | #
6 | # This program is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program. If not, see .
18 |
19 | import astroid
20 |
21 | from pylint.interfaces import IAstroidChecker
22 | from pylint.checkers import BaseChecker
23 | from pylint.checkers.utils import safe_infer
24 |
25 | from .utils import is_model
26 |
27 | class ModelFieldsChecker(BaseChecker):
28 | __implements__ = IAstroidChecker
29 |
30 | name = 'django_model_fields'
31 | msgs = {
32 | 'W6000': ('%s: Nullable CharField or TextField', 'nullable', 'Nullable'),
33 | 'W6001': (
34 | "%s: Naive tree structure implementation using ForeignKey('self')",
35 | 'naive-tree-structure',
36 | 'Naive tree structure',
37 | ),
38 | 'W6002': (
39 | 'Model has too many fields (%d/%d); consider splitting model',
40 | 'many-fields',
41 | 'Too many fields',
42 | ),
43 | 'W6003': ('Model has no fields', 'no-fields', 'No model fields'),
44 | 'W6004': (
45 | '%s: Field is nullable but blank=False',
46 | 'field-not-nullable',
47 | 'Field not nullable',
48 | ),
49 | 'W6005': ('%s: uses brittle unique_for_%s', 'brittle-unique', 'Brittle unique'),
50 | 'W6006': (
51 | '%s: ForeignKey missing related_name',
52 | 'missing-related-name',
53 | 'ForeignKey missing',
54 | ),
55 | 'W6007': (
56 | '%s: CharField with huge (%d/%d) max_length instead of TextField',
57 | 'huge-max-length',
58 | 'Huge charfield max_length',
59 | ),
60 | 'W6008': (
61 | '%s: Uses superceded auto_now or auto_now_add',
62 | 'superceded-auto',
63 | 'Superceded auto fields',
64 | ),
65 | 'W6009': (
66 | '%s: NullBooleanField instead of BooleanField with null=True',
67 | 'nullable-boolean-field',
68 | 'Nullable BooleanField',
69 | ),
70 | 'W6010': (
71 | '%s: %s has database-dependent limits',
72 | 'database-dependend',
73 | 'Database dependency',
74 | ),
75 | 'W6011': (
76 | '%s: URLField uses verify_exists=True default',
77 | 'verify-urlfield',
78 | 'URLField verify exists',
79 | ),
80 | 'W6012': (
81 | '%s: BooleanField with default=True will not be reflected in database',
82 | 'boolean-field-default',
83 | 'Boolean field with default',
84 | ),
85 | 'W6013': (
86 | '%s: Unique ForeignKey constraint better modelled as OneToOneField',
87 | 'unique-foreign-key',
88 | 'Use OneToOneField',
89 | ),
90 | 'W6014': (
91 | '%s: primary_key=True should imply unique=True',
92 | 'non-unique-primary',
93 | 'Non-unique primary key',
94 | ),
95 | 'W6015': ('%s: %s=False is implicit', 'implicit-false', 'Implicit false'),
96 | 'W6016': (
97 | '%s: Nullable ManyToManyField makes no sense',
98 | 'nullable-mtm',
99 | 'Nullable ManyToManyField',
100 | ),
101 | }
102 |
103 | options = (
104 | ('max-model-fields', {
105 | 'default': 20,
106 | 'type': 'int',
107 | 'metavar': '',
108 | 'help': 'Maximum number of fields for a model',
109 | }),
110 | ('max-charfield-length', {
111 | 'default': 512,
112 | 'type': 'int',
113 | 'metavar': '',
114 | 'help': 'Maximum size of max_length on a CharField',
115 | }),
116 | )
117 |
118 | def visit_module(self, node):
119 | self.field_count = 0
120 |
121 | def leave_class(self, node):
122 | if not is_model(node):
123 | return
124 |
125 | if is_model(node, check_base_classes=False) and self.field_count == 0:
126 | self.add_message('W6003', node=node)
127 | elif self.field_count > self.config.max_model_fields:
128 | self.add_message('W6002', node=node,
129 | args=(self.field_count, self.config.max_model_fields))
130 |
131 | self.field_count = 0
132 |
133 | def visit_callfunc(self, node):
134 | if not is_model(node.frame()):
135 | # We only care about fields attached to models
136 | return
137 |
138 | val = safe_infer(node)
139 | if not val or not val.root().name.startswith('django.db.models.fields'):
140 | # Not a field
141 | return
142 |
143 | assname = '(unknown name)'
144 | x = node.parent.get_children().next()
145 | if isinstance(x, astroid.AssName):
146 | assname = x.name
147 |
148 | self.field_count += 1
149 |
150 | # Parse kwargs
151 | options = dict([(option, None) for option in (
152 | 'null',
153 | 'blank',
154 | 'unique',
155 | 'default',
156 | 'auto_now',
157 | 'primary_key',
158 | 'auto_now_add',
159 | 'verify_exists',
160 | 'related_name',
161 | 'max_length',
162 | 'unique_for_date',
163 | 'unique_for_month',
164 | 'unique_for_year',
165 | )])
166 |
167 | for arg in node.args:
168 | if not isinstance(arg, astroid.Keyword):
169 | continue
170 |
171 | for option in options.keys():
172 | if arg.arg == option:
173 | try:
174 | options[option] = safe_infer(arg.value).value
175 | except AttributeError:
176 | # Don't lint this field if we cannot infer everything
177 | return
178 |
179 | if not val.name.lower().startswith('null'):
180 | for option in ('null', 'blank'):
181 | if options[option] is False:
182 | self.add_message('W6015', node=node, args=(assname, option,))
183 |
184 | # Field type specific checks
185 | if val.name in ('CharField', 'TextField'):
186 | if options['null']:
187 | self.add_message('W6000', node=node, args=(assname,))
188 |
189 | if val.name == 'CharField' and \
190 | options['max_length'] > self.config.max_charfield_length:
191 | self.add_message('W6007', node=node, args=(
192 | assname,
193 | options['max_length'],
194 | self.config.max_charfield_length,
195 | ))
196 |
197 | elif val.name == 'BooleanField':
198 | if options['default']:
199 | self.add_message('W6012', node=node, args=(assname,))
200 |
201 | elif val.name == 'ForeignKey':
202 | val = safe_infer(node.args[0])
203 | if isinstance(val, astroid.Const) and val.value == 'self':
204 | self.add_message('W6001', node=node, args=(assname,))
205 |
206 | elif not options['related_name']:
207 | self.add_message('W6006', node=node, args=(assname,))
208 |
209 | if options['primary_key'] and options['unique'] is False:
210 | self.add_message('W6014', node=node, args=(assname,))
211 | elif options['primary_key'] or options['unique']:
212 | self.add_message('W6013', node=node, args=(assname,))
213 |
214 | elif val.name == 'URLField':
215 | if options['verify_exists'] is None:
216 | self.add_message('W6011', node=node, args=(assname,))
217 |
218 | elif val.name in ('PositiveSmallIntegerField', 'SmallIntegerField'):
219 | self.add_message('W6010', node=node, args=(assname, val.name))
220 |
221 | elif val.name == 'NullBooleanField':
222 | self.add_message('W6009', node=node, args=(assname,))
223 |
224 | elif val.name == 'ManyToManyField':
225 | if options['null']:
226 | self.add_message('W6016', node=node, args=(assname,))
227 |
228 | # Generic checks
229 | if options['null'] and not options['blank']:
230 | self.add_message('W6004', node=node, args=(assname,))
231 |
232 | if options['auto_now'] or options['auto_now_add']:
233 | self.add_message('W6008', node=node, args=(assname,))
234 |
235 | for suffix in ('date', 'month', 'year'):
236 | if options['unique_for_%s' % suffix]:
237 | self.add_message('W6005', node=node, args=(assname, suffix))
238 |
--------------------------------------------------------------------------------
/DjangoLint/AstCheckers/model_methods.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # django-lint -- Static analysis tool for Django projects and applications
4 | # Copyright (C) 2008-2009 Chris Lamb
5 | #
6 | # This program is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program. If not, see .
18 |
19 | import os.path
20 |
21 | from pylint.interfaces import IAstroidChecker
22 | from pylint.checkers import BaseChecker
23 | from pylint.checkers.utils import safe_infer
24 |
25 | from .utils import is_model
26 |
27 | try:
28 | from itertools import combinations
29 | except ImportError:
30 | # Python <= 2.5 fallback
31 | def combinations(iterable, r):
32 | if r:
33 | for i, cur in enumerate(iterable):
34 | for xs in combinations(iterable[:i] + iterable[i + 1:], r - 1):
35 | yield [cur] + xs
36 | else:
37 | yield []
38 |
39 | class ModelMethodsChecker(BaseChecker):
40 | __implements__ = IAstroidChecker
41 |
42 | name = 'django_model_models'
43 | msgs = {
44 | 'W8010': (
45 | 'Too many models (%d/%d); consider splitting application',
46 | 'many-models',
47 | 'To many models',
48 | ),
49 | 'W8011': (
50 | 'Use __unicode__ instead of __str__',
51 | 'use-unicode',
52 | 'Use unicode',
53 | ),
54 | 'W8012': (
55 | 'Method should come after standard model methods',
56 | 'model-mathods-first',
57 | 'Model methods first',
58 | ),
59 | 'W8013': (
60 | '%s should come before %r',
61 | 'method-first',
62 | 'Wrong method order',
63 | ),
64 | 'W8015': (
65 | '%d models have common prefix (%r) - rename or split application',
66 | 'common-prefix',
67 | 'Common application prefix',
68 | ),
69 | }
70 |
71 | options = (
72 | ('max-models', {
73 | 'default': 10,
74 | 'type': 'int',
75 | 'metavar': '',
76 | 'help': 'Maximum number of models per module',
77 | }),
78 | )
79 |
80 | def visit_module(self, node):
81 | self.model_names = []
82 |
83 | def leave_module(self, node):
84 | if len(self.model_names) >= self.config.max_models:
85 | self.add_message('W8010', node=node.root(),
86 | args=(len(self.model_names), self.config.max_models))
87 |
88 | if not self.model_names:
89 | return
90 |
91 | for names in combinations(self.model_names, 4):
92 | common = os.path.commonprefix(names)
93 | if len(common) >= 4:
94 | # Whitelist a few common names
95 | if common.lower() in ('abstract',):
96 | continue
97 |
98 | # How many actually have this prefix?
99 | xs = filter(lambda x: x.startswith(common), self.model_names)
100 |
101 | self.add_message('W8015', node=node.root(),
102 | args=(len(xs), common,))
103 | break
104 |
105 | def _visit_django_attribute(self, node, is_method=True):
106 | try:
107 | idx = [
108 | 'Meta',
109 | '__unicode__',
110 | '__str__',
111 | 'save',
112 | 'delete',
113 | 'get_absolute_url',
114 | ].index(node.name)
115 |
116 | if self.prev_idx == -1:
117 | self.add_message('W8012', node=self.prev_node)
118 |
119 | elif idx < self.prev_idx:
120 | noun = is_method and 'Standard model method' or '"Meta" class'
121 | self.add_message(
122 | 'W8013', node=node, args=(noun, self.prev_node.name)
123 | )
124 |
125 | except ValueError:
126 | idx = -1
127 |
128 | self.prev_idx = idx
129 | self.prev_node = node
130 |
131 | def visit_function(self, node):
132 | if not is_model(node.parent.frame()):
133 | return
134 |
135 | if node.name == '__str__':
136 | self.add_message('W8011', node=node)
137 |
138 | self._visit_django_attribute(node)
139 |
140 | def visit_class(self, node):
141 | if is_model(node):
142 | self.model_names.append(node.name)
143 | self.prev_idx = None
144 | self.prev_node = None
145 |
146 | elif is_model(node.parent.frame()):
147 | # Nested class
148 | self._visit_django_attribute(node, is_method=False)
149 |
150 | def visit_assname(self, node):
151 | if not is_model(node.parent.frame()):
152 | return
153 |
154 | if self.prev_idx >= 0:
155 | self.add_message('W8013', node=node, args=(
156 | '%r assignment' % node.name, self.prev_node.name,
157 | ))
158 |
159 | def leave_class(self, node):
160 | if node.name == 'Meta' and is_model(node.parent.parent):
161 | # Annotate the model with information from the Meta class
162 | try:
163 | val = safe_infer(node.locals['abstract'][-1]).value
164 | if val is True:
165 | node.parent.parent._django_abstract = True
166 | except KeyError:
167 | pass
168 | return
169 |
170 | if not is_model(node):
171 | return
172 |
--------------------------------------------------------------------------------
/DjangoLint/AstCheckers/settings.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # django-lint -- Static analysis tool for Django projects and applications
4 | # Copyright (C) 2008-2009 Chris Lamb
5 | #
6 | # This program is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program. If not, see .
18 |
19 | import astroid
20 |
21 | from pylint.interfaces import IAstroidChecker
22 | from pylint.checkers import BaseChecker
23 | from pylint.checkers.utils import safe_infer
24 |
25 | class SettingsChecker(BaseChecker):
26 | __implements__ = IAstroidChecker
27 |
28 | name = 'django_settings_checker'
29 | msgs = {
30 | 'W7001': (
31 | 'Missing required field %r',
32 | 'missing-required',
33 | 'Required field missing',
34 | ),
35 | 'W7002': (
36 | 'Empty %r setting',
37 | 'empty-setting',
38 | 'Empty setting',
39 | ),
40 | 'W7003': (
41 | '%s after %s',
42 | 'middlware-order',
43 | 'Wrong middleware order',
44 | ),
45 | 'W7005': (
46 | 'Non-absolute directory %r in TEMPLATE_DIRS',
47 | 'non-absolute-dir',
48 | 'Non-absolute directory',
49 | ),
50 | 'W7006': (
51 | '%r in TEMPLATE_DIRS should use forward slashes',
52 | 'backward-slashes',
53 | 'Backward slashes',
54 | ),
55 | }
56 |
57 | def leave_module(self, node):
58 | if node.name.split('.')[-1] != 'settings':
59 | return
60 |
61 | self.check_required_fields(node)
62 | self.check_middleware(node)
63 | self.check_template_dirs(node)
64 |
65 | def check_required_fields(self, node):
66 | REQUIRED_FIELDS = {
67 | 'DEBUG': bool,
68 | 'TEMPLATE_DEBUG': bool,
69 | 'INSTALLED_APPS': tuple,
70 | 'MANAGERS': tuple,
71 | 'ADMINS': tuple,
72 | 'MIDDLEWARE_CLASSES': tuple,
73 | }
74 |
75 | for field, req_type in REQUIRED_FIELDS.items():
76 | if field not in node.locals.keys():
77 | self.add_message('W7001', args=field, node=node)
78 | continue
79 |
80 | if req_type is tuple:
81 | ass = node.locals[field][-1]
82 | val = safe_infer(ass)
83 |
84 | if val and not val.get_children():
85 | self.add_message('W7002', args=field, node=ass)
86 |
87 | def get_constant_values(self, node, key):
88 | try:
89 | ass = node.locals[key][-1]
90 | except KeyError:
91 | return
92 |
93 | try:
94 | xs = safe_infer(ass).get_children()
95 | except AttributeError:
96 | return
97 |
98 | try:
99 | xs_iterable = iter(xs)
100 | except TypeError:
101 | return
102 |
103 | return [(x, x.value) for x in xs if isinstance(safe_infer(x), astroid.Const)]
104 |
105 | def check_middleware(self, node):
106 | middleware = self.get_constant_values(node, 'MIDDLEWARE_CLASSES')
107 | if middleware is None:
108 | return
109 |
110 | relations = ((
111 | 'django.contrib.sessions.middleware.SessionMiddleware',
112 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
113 | ), (
114 | 'django.middleware.http.ConditionalGetMiddleware',
115 | 'django.middleware.common.CommonMiddleware',
116 | ))
117 |
118 | lookup = [y for x, y in middleware]
119 | node_lookup = dict([(y, x) for x, y in middleware])
120 |
121 | for a, b in relations:
122 | try:
123 | if lookup.index(a) > lookup.index(b):
124 | self.add_message(
125 | 'W7003',
126 | args=tuple([x.split('.')[-1] for x in (a, b)]),
127 | node=node_lookup[a],
128 | )
129 | except ValueError:
130 | pass
131 |
132 | def check_template_dirs(self, node):
133 | template_dirs = self.get_constant_values(node, 'TEMPLATE_DIRS')
134 | if template_dirs is None:
135 | return
136 |
137 | for dirnode, dirname in template_dirs:
138 | if not (dirname.startswith('/') or dirname[1:].startswith(':')):
139 | self.add_message('W7005', args=dirname, node=dirnode)
140 |
141 | if dirname.find('\\') > 0:
142 | self.add_message('W7006', args=dirname, node=dirnode)
143 |
--------------------------------------------------------------------------------
/DjangoLint/AstCheckers/size.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # django-lint -- Static analysis tool for Django projects and applications
4 | # Copyright (C) 2008-2009 Chris Lamb
5 | #
6 | # This program is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program. If not, see .
18 |
19 | from pylint.interfaces import IAstroidChecker
20 | from pylint.checkers import BaseChecker
21 |
22 | class SizeChecker(BaseChecker):
23 | __implements__ = IAstroidChecker
24 |
25 | name = 'django_size_checker'
26 | msgs = {
27 | 'W8001': (
28 | '%r is actually a directory; consider splitting application',
29 | 'models-as-directory',
30 | 'Models as directory',
31 | ),
32 | }
33 |
34 | def leave_module(self, node):
35 | for candidate in ('views', 'models'):
36 | if not node.name.endswith('.%s' % candidate):
37 | continue
38 |
39 | if node.file.endswith('__init__.py'):
40 | # When 'models' is a directory, django.test.simple.run_tests
41 | # cannot tell the difference between a tests.py module that is
42 | # raising an ImportError and when it doesn't exist (so it
43 | # silently discards that app). This is not good!
44 | self.add_message('W8001', args=node.name, node=node)
45 |
--------------------------------------------------------------------------------
/DjangoLint/AstCheckers/utils.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | # django-lint -- Static analysis tool for Django projects and applications
4 | # Copyright (C) 2008-2009 Chris Lamb
5 | #
6 | # This program is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the License, or
9 | # (at your option) any later version.
10 | #
11 | # This program is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with this program. If not, see .
18 |
19 | import astroid
20 |
21 | from itertools import chain
22 | from pylint.checkers.utils import safe_infer
23 |
24 | def is_model(node, **kwargs):
25 | return nodeisinstance(node, ('django.db.models.base.Model',), **kwargs)
26 |
27 | def nodeisinstance(node, klasses, check_base_classes=True):
28 | if not isinstance(node, astroid.ClassDef):
29 | return False
30 |
31 | for base in node.bases:
32 | val = safe_infer(base)
33 | if not val:
34 | continue
35 | if isinstance(val, astroid.bases._Yes):
36 | continue
37 |
38 | nodes = [val]
39 | if check_base_classes:
40 | try:
41 | nodes = chain([val], val.ancestors())
42 | except TypeError:
43 | pass
44 |
45 | for node in nodes:
46 | qual = '%s.%s' % (node.root().name, node.name)
47 | if qual in klasses:
48 | return True
49 |
50 | return False
51 |
--------------------------------------------------------------------------------
/DjangoLint/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lamby/django-lint/6b52a895b180c36bdc8c771cfc9ab084a9e30c5f/DjangoLint/__init__.py
--------------------------------------------------------------------------------
/DjangoLint/script.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 |
4 | # django-lint -- Static analysis tool for Django projects and applications
5 | # Copyright (C) 2008-2009 Chris Lamb
6 | #
7 | # This program is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation, either version 3 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program. If not, see .
19 |
20 | import os
21 | import sys
22 |
23 | from pylint import checkers, lint, reporters
24 | from pylint.reporters import text as text_reporter
25 | from optparse import OptionParser
26 |
27 | from DjangoLint import AstCheckers
28 |
29 | def main():
30 | usage = """ %prog [options] target
31 |
32 | Django Lint is a tool that statically analyses Django projects and
33 | applications, checking for programming errors and bad code smells. For
34 | example, it reports nullable "CharField" fields, as well as reporting for
35 | unspecified options in settings.py.
36 |
37 | The `target` argument is mandatory and can specify either a directory
38 | containing a Django project, a single application or a single file.
39 | """.rstrip()
40 |
41 | parser = OptionParser(usage=usage)
42 | parser.add_option(
43 | '-r',
44 | '--reports',
45 | dest='report',
46 | action='store_true',
47 | default=False,
48 | help='generate report',
49 | )
50 | parser.add_option(
51 | '-p',
52 | '--pylint',
53 | dest='pylint',
54 | action='store_true',
55 | default=False,
56 | help='run normal PyLint checks',
57 | )
58 | parser.add_option(
59 | '-e',
60 | '--errors',
61 | dest='errors',
62 | action='store_true',
63 | default=False,
64 | help='only show errors',
65 | )
66 | parser.add_option(
67 | '-f',
68 | '--format',
69 | dest='outputformat',
70 | metavar='OUTPUT',
71 | default='text',
72 | help='Set the output format. Available formats are text,'
73 | 'parseable, colorized, msvs (visual studio) and html',
74 | )
75 |
76 | options, args = parser.parse_args()
77 |
78 | try:
79 | args[0]
80 | except IndexError:
81 | args = ['.']
82 |
83 | targets = [os.path.abspath(arg) for arg in args]
84 |
85 | for target in targets:
86 | if not os.path.exists(target):
87 | try:
88 | # Is target a module?
89 | x = __import__(args[0], locals(), globals(), [], -1)
90 | target = sys.modules[args[0]].__path__[0]
91 | except:
92 | pass
93 |
94 | if not os.path.exists(target):
95 | raise parser.error(
96 | "The specified target (%r) does not exist" \
97 | % target
98 | )
99 |
100 | path = target
101 | while True:
102 | flag = False
103 | for django_file in ('manage.py', 'models.py', 'urls.py'):
104 | if os.path.exists(os.path.join(path, django_file)):
105 | sys.path.insert(0, os.path.dirname(path))
106 | flag = True
107 | break
108 | if flag:
109 | break
110 |
111 | path = os.path.dirname(path)
112 |
113 | if path == '/':
114 | raise parser.error(
115 | "The specified target (%r) does not appear to be part of a " \
116 | "Django application" % target
117 | )
118 |
119 | try:
120 | import django
121 | except ImportError:
122 | print >>sys.stderr, "E: Cannot import `django' module, exiting.."
123 | return 1
124 |
125 | linter = lint.PyLinter()
126 | linter.set_reporter(text_reporter.TextReporter())
127 | linter.set_option('reports', options.report)
128 | linter.set_option('output-format', options.outputformat)
129 |
130 | if options.pylint:
131 | checkers.initialize(linter)
132 | for msg in ('C0111', 'C0301'):
133 | linter.disable(msg)
134 |
135 | AstCheckers.register(linter)
136 |
137 | if options.errors:
138 | linter.set_option('disable-msg-cat', 'WCRI')
139 | linter.set_option('reports', False)
140 | linter.set_option('persistent', False)
141 |
142 | linter.check(targets)
143 |
144 | return linter.msg_status
145 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # `django-lint`
2 |
3 | ## Important notice
4 |
5 | This project has been 2008 and was maintained until 2011; it has since been
6 | deprecated. If you wish to check out similar functionality, please see:
7 |
8 | * Richard Tier's [Django Doctor](https://django.doctor/)
9 |
10 | ## Ideas
11 |
12 | ### General
13 |
14 | * Default manager with restrictive get\_query\_set()
15 | * Oldforms (?)
16 | * Overriding definition of model. e.g.:
17 |
18 | class MyModel(models.Model):
19 |
20 | : foo = \[..\]
21 |
22 | foo = \[..\]
23 |
24 | * Not importing settings via \"django.conf import settings\"
25 | * Not using reverse (or \@permalink) in get\_absolute\_url (?)
26 | * Form definitions in models.py
27 | * Ignore tests
28 |
29 | ### Models
30 |
31 | * Don\'t count ManyToMany fields on a model as a field
32 | > Remove common prefix checking.
33 | > models.. specifying \"objects = \" should be last
34 |
35 | ### Views
36 |
37 | * Calling request.is\_authenticated without actually calling
38 | > function
39 | * order\_by(\'?\')
40 | * request.method.upper is a no-op (etc.)
41 | * cache.set without a timeout
42 |
43 | ### URLS
44 |
45 | * Unreversible urlpatterns
46 |
47 | #### Layout
48 |
49 | > - Form class not in forms.py
50 | > - Admin class not in admin.py
51 |
52 | #### Templates
53 |
54 | * {% if foo %}{{ foo }}{% else %}bar{% endif %} =\> {{
55 | foo\|default:\"bar\" }}
56 | * {% with foo as bar %} \... \[ not using {{ bar }} \] \... {%
57 | endwith %}
58 | * {% endblock %} vs. {% endblock blockname %}
59 |
60 | #### Settings
61 |
62 | * Ordering of MIDDLEWARE\_CLASSES
63 | * `TEMPLATE_DIRS` not absolute
64 |
65 | #### Layout
66 |
67 | * forms not in forms.py managers not in managers.py
68 |
--------------------------------------------------------------------------------
/django-lint:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 |
4 | # django-lint -- Static analysis tool for Django projects and applications
5 | # Copyright (C) 2008-2009 Chris Lamb
6 | #
7 | # This program is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation, either version 3 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program. If not, see .
19 |
20 | import sys
21 |
22 | from DjangoLint import script
23 |
24 | if __name__ == "__main__":
25 | sys.exit(script.main())
26 |
--------------------------------------------------------------------------------
/django-lint.1:
--------------------------------------------------------------------------------
1 | .TH DJANGO-LINT 1 "Jan 11, 2009"
2 | .SH NAME
3 | django-lint - static analyser for Django projects and applications
4 | .SH SYNOPSIS
5 | .PP
6 | \fBdjango-lint \fR\fI[options]\fR \fr\fItarget\fR
7 | .SH DESCRIPTION
8 | .PP
9 | Django Lint is a tool that statically analyses projects and applications
10 | that use the Django web development framework.
11 | .PP
12 | It checks and reports on common programming errors and bad code smells
13 | including nullable "CharField" fields, the use of brittle Django features
14 | such as "auto_now_add" and unspecified recommended options in settings.py,
15 | such as an empty 'ADMINS' setting (plus many more).
16 | .PP
17 | The \fBtarget\fR argument is mandatory and can specify either a directory
18 | containing a Django project, a single application or a single file.
19 | .SH "AUTHOR"
20 | .PP
21 | Django Lint and this manual page were written by Chris Lamb .
22 | .PP
23 | This manual page is (C) 2008 by Chris Lamb and is licensed under the terms of
24 | the GPLv3 or higher.
25 |
--------------------------------------------------------------------------------
/django_lint_example/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lamby/django-lint/6b52a895b180c36bdc8c771cfc9ab084a9e30c5f/django_lint_example/__init__.py
--------------------------------------------------------------------------------
/django_lint_example/example/__init__.py:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/django_lint_example/example/models/__init__.py:
--------------------------------------------------------------------------------
1 | from django.db import models
2 | from django.contrib import admin
3 |
4 | class NullableModel(models.Model):
5 | TRUTH_VALUE = True
6 |
7 | charfield = models.CharField(max_length=100, null=True, blank=True)
8 | charfield_2 = models.CharField(max_length=100, null=TRUTH_VALUE)
9 | textfield = models.TextField(null=True, blank=True)
10 |
11 | boolean_false = models.BooleanField(default=True)
12 |
13 | nullable_boolean = models.NullBooleanField()
14 |
15 | # We should still report about the following field, but we cannot
16 | # determine its name.
17 | models.NullBooleanField()
18 |
19 | class UniqueForModels(models.Model):
20 | time = models.DateTimeField()
21 | u_date = models.IntegerField(unique_for_date='time')
22 | u_month = models.IntegerField(unique_for_month='time')
23 | u_year = models.IntegerField(unique_for_year='time')
24 |
25 | class ParentModel(models.Model):
26 | parent = models.ForeignKey('self')
27 |
28 | class StrModel(models.Model):
29 | dummy = models.CharField(max_length=1)
30 |
31 | def __str__(self):
32 | return "__str__ method"
33 |
34 | def __unicode__(self):
35 | return self.dummy
36 |
37 | class NullBlankModel(models.Model):
38 | number = models.IntegerField(blank=True)
39 |
40 | class BigModel(models.Model):
41 | field01 = models.IntegerField()
42 | field02 = models.IntegerField()
43 | field03 = models.IntegerField()
44 | field04 = models.IntegerField()
45 | field05 = models.IntegerField()
46 | field06 = models.IntegerField()
47 | field07 = models.IntegerField()
48 | field08 = models.IntegerField()
49 | field09 = models.IntegerField()
50 | field10 = models.IntegerField()
51 | field11 = models.IntegerField()
52 | field12 = models.IntegerField()
53 | field13 = models.IntegerField()
54 | field14 = models.IntegerField()
55 | field15 = models.IntegerField()
56 | field16 = models.IntegerField()
57 | field17 = models.IntegerField()
58 | field18 = models.IntegerField()
59 | field19 = models.IntegerField()
60 | field20 = models.IntegerField()
61 | field21 = models.IntegerField()
62 | field22 = models.IntegerField()
63 | field23 = models.IntegerField()
64 | field24 = models.IntegerField()
65 | field25 = models.IntegerField()
66 | field26 = models.IntegerField()
67 | field27 = models.IntegerField()
68 | field28 = models.IntegerField()
69 | field29 = models.IntegerField()
70 | field30 = models.IntegerField()
71 | field31 = models.IntegerField()
72 |
73 | class NoFieldsModel(models.Model):
74 | pass
75 |
76 | class Post(models.Model):
77 | title = models.CharField(max_length=100)
78 | content = models.CharField(max_length=1000)
79 | views = models.PositiveSmallIntegerField()
80 | words = models.SmallIntegerField()
81 | created = models.DateTimeField(auto_now_add=True)
82 | updated = models.DateTimeField(auto_now=True)
83 |
84 | def __unicode__(self):
85 | return self.title
86 |
87 | class Comment(models.Model):
88 | post = models.ForeignKey(Post)
89 | url = models.URLField()
90 |
91 | def __unicode__(self):
92 | return self.url
93 |
94 | class MisorderedMethodsModel(models.Model):
95 | dummy = models.CharField(max_length=1)
96 |
97 | def incorrect_place(self):
98 | pass
99 |
100 | def get_absolute_url(self):
101 | pass
102 |
103 | def __unicode__(self):
104 | # This should be swapped with get_absolute_url
105 | pass
106 |
107 | def correct_place(self):
108 | pass
109 |
110 | class Model1(models.Model):
111 | dummy = models.CharField(max_length=1)
112 |
113 | class Meta:
114 | verbose_name_plural = 'right'
115 |
116 | def __unicode__(self):
117 | return self.dummy
118 |
119 | class Model2(models.Model):
120 | dummy = models.CharField(max_length=1)
121 |
122 | def __unicode__(self):
123 | return self.dummy
124 |
125 | class Meta:
126 | verbose_name_plural = 'wrong'
127 |
128 | class Model3(models.Model):
129 | class Meta:
130 | verbose_name_plural = 'wrong'
131 |
132 | dummy = models.CharField(max_length=1)
133 |
134 | def __unicode__(self):
135 | return self.dummy
136 |
137 | class Model4(models.Model):
138 | dummy = models.CharField(max_length=1)
139 |
140 | def __unicode__(self):
141 | return self.dummy
142 |
143 | class Model5(models.Model):
144 | dummy = models.CharField(max_length=1)
145 |
146 | def get_absolute_url(self):
147 | return "/"
148 |
149 | def __unicode__(self):
150 | return self.dummy
151 |
152 | class AbstractModel(models.Model):
153 | foo = models.CharField(max_length=1)
154 |
155 | class Meta:
156 | abstract = True
157 |
158 | class DerivedModel(AbstractModel):
159 | bar = models.CharField(max_length=1)
160 |
161 | class WeirdPrimaryKeyModel(models.Model):
162 | primary_key = models.ForeignKey(Model1, primary_key=True)
163 | unique_field = models.ForeignKey(Model2, unique=True)
164 | not_both = models.ForeignKey(Model3, primary_key=True, unique=False)
165 |
166 | class ManyToManyModel(models.Model):
167 | nullable = models.ManyToManyField(Model2, null=True)
168 | blank = models.ManyToManyField(Model3, blank=True)
169 |
170 | class AdminKlass(admin.ModelAdmin):
171 | search_fields = ('nullable',)
172 |
173 | class Meta:
174 | model = ManyToManyModel
175 |
--------------------------------------------------------------------------------
/django_lint_example/example/views.py:
--------------------------------------------------------------------------------
1 | # Create your views here.
2 |
--------------------------------------------------------------------------------
/django_lint_example/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python
2 | from django.core.management import execute_manager
3 | try:
4 | import settings # Assumed to be in the same directory.
5 | except ImportError:
6 | import sys
7 | sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
8 | sys.exit(1)
9 |
10 | if __name__ == "__main__":
11 | execute_manager(settings)
12 |
--------------------------------------------------------------------------------
/django_lint_example/settings.py:
--------------------------------------------------------------------------------
1 | # Django settings for django_lint_example project.
2 |
3 | DEBUG = True
4 | TEMPLATE_DEBUG = DEBUG
5 |
6 | ADMINS = (
7 | # ('Your Name', 'your_email@domain.com'),
8 | )
9 |
10 | MANAGERS_MISSING = ADMINS
11 |
12 | DATABASE_ENGINE = '' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
13 | DATABASE_NAME = '' # Or path to database file if using sqlite3.
14 | DATABASE_USER = '' # Not used with sqlite3.
15 | DATABASE_PASSWORD = '' # Not used with sqlite3.
16 | DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
17 | DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
18 |
19 | # Local time zone for this installation. Choices can be found here:
20 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
21 | # although not all choices may be available on all operating systems.
22 | # If running in a Windows environment this must be set to the same as your
23 | # system time zone.
24 | TIME_ZONE = 'America/Chicago'
25 |
26 | # Language code for this installation. All choices can be found here:
27 | # http://www.i18nguy.com/unicode/language-identifiers.html
28 | LANGUAGE_CODE = 'en-us'
29 |
30 | SITE_ID = 1
31 |
32 | # If you set this to False, Django will make some optimizations so as not
33 | # to load the internationalization machinery.
34 | USE_I18N = True
35 |
36 | # Absolute path to the directory that holds media.
37 | # Example: "/home/media/media.lawrence.com/"
38 | MEDIA_ROOT = ''
39 |
40 | # URL that handles the media served from MEDIA_ROOT. Make sure to use a
41 | # trailing slash if there is a path component (optional in other cases).
42 | # Examples: "http://media.lawrence.com", "http://example.com/media/"
43 | MEDIA_URL = ''
44 |
45 | # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
46 | # trailing slash.
47 | # Examples: "http://foo.com/media/", "/media/".
48 | ADMIN_MEDIA_PREFIX = '/media/'
49 |
50 | # Make this unique, and don't share it with anybody.
51 | SECRET_KEY = 'r_t-fx@9&8nuxf!i!07@@wo-yto%wk=p(-i$(4*612ukhdt4g&'
52 |
53 | # List of callables that know how to import templates from various sources.
54 | TEMPLATE_LOADERS = (
55 | 'django.template.loaders.filesystem.load_template_source',
56 | 'django.template.loaders.app_directories.load_template_source',
57 | # 'django.template.loaders.eggs.load_template_source',
58 | )
59 |
60 | MIDDLEWARE_CLASSES = (
61 | 'django.middleware.common.CommonMiddleware',
62 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
63 | 'django.contrib.sessions.middleware.SessionMiddleware',
64 | 'django.middleware.common.CommonMiddleware',
65 | 'django.middleware.http.ConditionalGetMiddleware',
66 | )
67 |
68 | ROOT_URLCONF = 'django_lint_example.urls'
69 |
70 | TEMPLATE_DIRS = (
71 | # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
72 | # Always use forward slashes, even on Windows.
73 | # Don't forget to use absolute paths, not relative paths.
74 | 'relative/directory',
75 | 'C:\windows\user',
76 | )
77 |
78 | INSTALLED_APPS = (
79 | 'django.contrib.auth',
80 | 'django.contrib.contenttypes',
81 | 'django.contrib.sessions',
82 | 'django.contrib.sites',
83 | 'example',
84 | )
85 |
--------------------------------------------------------------------------------
/django_lint_example/urls.py:
--------------------------------------------------------------------------------
1 | from django.conf.urls.defaults import *
2 |
3 | # Uncomment the next two lines to enable the admin:
4 | # from django.contrib import admin
5 | # admin.autodiscover()
6 |
7 | urlpatterns = patterns('',
8 | # Example:
9 | # (r'^django_lint_example/', include('django_lint_example.foo.urls')),
10 |
11 | # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
12 | # to INSTALLED_APPS to enable admin documentation:
13 | # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
14 |
15 | # Uncomment the next line to enable the admin:
16 | # (r'^admin/(.*)', admin.site.root),
17 | )
18 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 |
4 | # django-lint -- Static analysis tool for Django projects and applications
5 | # Copyright (C) 2008-2009 Chris Lamb
6 | #
7 | # This program is free software: you can redistribute it and/or modify
8 | # it under the terms of the GNU General Public License as published by
9 | # the Free Software Foundation, either version 3 of the License, or
10 | # (at your option) any later version.
11 | #
12 | # This program is distributed in the hope that it will be useful,
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | # GNU General Public License for more details.
16 | #
17 | # You should have received a copy of the GNU General Public License
18 | # along with this program. If not, see .
19 |
20 | setup_args = dict(
21 | name='django-lint',
22 | url="https://chris-lamb.co.uk/projects/django-lint",
23 | version='2.0.4',
24 | license="BSD",
25 | description="Static analysis tool for Django projects.",
26 | packages=[
27 | 'DjangoLint',
28 | 'DjangoLint.AstCheckers',
29 | ],
30 | author='Chris Lamb',
31 | author_email='chris@chris-lamb.co.uk',
32 |
33 | install_requires=(
34 | 'Django>=1.8',
35 | ),
36 | )
37 |
38 | try:
39 | from setuptools import setup
40 | setup_args['entry_points'] = {
41 | "console_scripts" : ['django-lint = DjangoLint.script:main',]
42 | }
43 | setup_args['install_requires'] = ['pylint']
44 | except ImportError:
45 | from distutils.core import setup
46 | setup_args['scripts']=['django-lint',]
47 | setup_args['requires'] = ['pylint']
48 |
49 | setup(**setup_args)
50 |
--------------------------------------------------------------------------------