From 241ef68f4faec1c86d721a2b15c5e6271a1f5c14 Mon Sep 17 00:00:00 2001
From: Calen Pennington <calen.pennington@gmail.com>
Date: Wed, 15 May 2013 09:44:47 -0400
Subject: [PATCH] Start linting envs files, add task to only pylint errors, and
 move pylintrc file to the correct location

---
 cms/envs/acceptance.py         |  5 +++++
 cms/envs/aws.py                |  5 +++++
 cms/envs/common.py             |  4 ++++
 cms/envs/dev.py                |  4 ++++
 cms/envs/dev_ike.py            |  4 ++++
 cms/envs/jasmine.py            |  4 ++++
 cms/envs/test.py               |  5 +++++
 lms/envs/acceptance.py         |  5 +++++
 lms/envs/aws.py                |  5 +++++
 lms/envs/cms/acceptance.py     |  5 +++++
 lms/envs/cms/aws.py            |  4 ++++
 lms/envs/cms/dev.py            |  4 ++++
 lms/envs/cms/preview_dev.py    |  4 ++++
 lms/envs/common.py             |  5 +++++
 lms/envs/content.py            |  5 +++++
 lms/envs/dev.py                |  5 +++++
 lms/envs/dev_edx4edx.py        |  4 ++++
 lms/envs/dev_ike.py            |  5 +++++
 lms/envs/dev_int.py            |  5 +++++
 lms/envs/dev_mongo.py          |  5 +++++
 lms/envs/devgroups/courses.py  |  5 +++++
 lms/envs/devgroups/h_cs50.py   |  5 +++++
 lms/envs/devgroups/m_6002.py   |  5 +++++
 lms/envs/devgroups/portal.py   |  5 +++++
 lms/envs/devplus.py            |  5 +++++
 lms/envs/discussionsettings.py |  4 ++++
 lms/envs/edx4edx_aws.py        |  4 ++++
 lms/envs/jasmine.py            |  4 ++++
 lms/envs/static.py             |  5 +++++
 lms/envs/test.py               |  5 +++++
 lms/envs/test_ike.py           |  5 +++++
 .pylintrc => pylintrc          |  0
 rakefiles/quality.rake         | 40 +++++++++++++++++++++++-----------
 33 files changed, 171 insertions(+), 13 deletions(-)
 rename .pylintrc => pylintrc (100%)

diff --git a/cms/envs/acceptance.py b/cms/envs/acceptance.py
index f4b867d3c62..97bb0011f2d 100644
--- a/cms/envs/acceptance.py
+++ b/cms/envs/acceptance.py
@@ -2,6 +2,11 @@
 This config file extends the test environment configuration
 so that we can run the lettuce acceptance tests.
 """
+
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 from .test import *
 
 # You need to start the server in debug mode,
diff --git a/cms/envs/aws.py b/cms/envs/aws.py
index 3cd70826da3..9fabb3b9e85 100644
--- a/cms/envs/aws.py
+++ b/cms/envs/aws.py
@@ -1,6 +1,11 @@
 """
 This is the default template for our main set of AWS servers.
 """
+
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 import json
 
 from .common import *
diff --git a/cms/envs/common.py b/cms/envs/common.py
index e150374cefd..038c00ddbbe 100644
--- a/cms/envs/common.py
+++ b/cms/envs/common.py
@@ -19,6 +19,10 @@ Longer TODO:
    multiple sites, but we do need a way to map their data assets.
 """
 
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 import sys
 import lms.envs.common
 from path import path
diff --git a/cms/envs/dev.py b/cms/envs/dev.py
index f3080c356fe..203e4bd909d 100644
--- a/cms/envs/dev.py
+++ b/cms/envs/dev.py
@@ -1,6 +1,10 @@
 """
 This config file runs the simplest dev environment"""
 
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 from .common import *
 from logsettings import get_logger_config
 
diff --git a/cms/envs/dev_ike.py b/cms/envs/dev_ike.py
index 1ebf219d44a..0c798b68aa5 100644
--- a/cms/envs/dev_ike.py
+++ b/cms/envs/dev_ike.py
@@ -1,3 +1,7 @@
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 # dev environment for ichuang/mit
 
 # FORCE_SCRIPT_NAME = '/cms'
diff --git a/cms/envs/jasmine.py b/cms/envs/jasmine.py
index 6c7cbcdcb07..f3a982aa432 100644
--- a/cms/envs/jasmine.py
+++ b/cms/envs/jasmine.py
@@ -2,6 +2,10 @@
 This configuration is used for running jasmine tests
 """
 
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 from .test import *
 from logsettings import get_logger_config
 
diff --git a/cms/envs/test.py b/cms/envs/test.py
index 4cb975e2fbf..6d78b0d7d61 100644
--- a/cms/envs/test.py
+++ b/cms/envs/test.py
@@ -7,6 +7,11 @@ sessions. Assumes structure:
         /mitx # The location of this repo
         /log  # Where we're going to write log files
 """
+
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 from .common import *
 import os
 from path import path
diff --git a/lms/envs/acceptance.py b/lms/envs/acceptance.py
index 611c3fdac86..3b87bb43260 100644
--- a/lms/envs/acceptance.py
+++ b/lms/envs/acceptance.py
@@ -2,6 +2,11 @@
 This config file extends the test environment configuration
 so that we can run the lettuce acceptance tests.
 """
+
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 from .test import *
 
 # You need to start the server in debug mode,
diff --git a/lms/envs/aws.py b/lms/envs/aws.py
index bec2671d5ec..df80d5a9243 100644
--- a/lms/envs/aws.py
+++ b/lms/envs/aws.py
@@ -6,6 +6,11 @@ Common traits:
 * Use memcached, and cache-backed sessions
 * Use a MySQL 5.1 database
 """
+
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 import json
 
 from .common import *
diff --git a/lms/envs/cms/acceptance.py b/lms/envs/cms/acceptance.py
index e5ee2937f4f..0b638dca8ae 100644
--- a/lms/envs/cms/acceptance.py
+++ b/lms/envs/cms/acceptance.py
@@ -3,6 +3,11 @@ This config file is a copy of dev environment without the Debug
 Toolbar. I it suitable to run against acceptance tests.
 
 """
+
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 from .dev import *
 
 #  REMOVE DEBUG TOOLBAR
diff --git a/lms/envs/cms/aws.py b/lms/envs/cms/aws.py
index a0e2f25d830..baeaebca1c6 100644
--- a/lms/envs/cms/aws.py
+++ b/lms/envs/cms/aws.py
@@ -2,6 +2,10 @@
 Settings for the LMS that runs alongside the CMS on AWS
 """
 
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 from ..aws import *
 
 with open(ENV_ROOT / "cms.auth.json") as auth_file:
diff --git a/lms/envs/cms/dev.py b/lms/envs/cms/dev.py
index 9333b7883c7..e55c6d61b51 100644
--- a/lms/envs/cms/dev.py
+++ b/lms/envs/cms/dev.py
@@ -2,6 +2,10 @@
 Settings for the LMS that runs alongside the CMS on AWS
 """
 
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 from ..dev import *
 
 MITX_FEATURES['AUTH_USE_MIT_CERTIFICATES'] = False
diff --git a/lms/envs/cms/preview_dev.py b/lms/envs/cms/preview_dev.py
index 463af34624a..1cfaec6159d 100644
--- a/lms/envs/cms/preview_dev.py
+++ b/lms/envs/cms/preview_dev.py
@@ -2,6 +2,10 @@
 Settings for the LMS that runs alongside the CMS on AWS
 """
 
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 from .dev import *
 
 MODULESTORE = {
diff --git a/lms/envs/common.py b/lms/envs/common.py
index a198f010c6e..3c133a1e6b8 100644
--- a/lms/envs/common.py
+++ b/lms/envs/common.py
@@ -18,6 +18,11 @@ Longer TODO:
 3. We need to handle configuration for multiple courses. This could be as
    multiple sites, but we do need a way to map their data assets.
 """
+
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 import sys
 import os
 
diff --git a/lms/envs/content.py b/lms/envs/content.py
index f6991538954..f85ae0b9cd3 100644
--- a/lms/envs/content.py
+++ b/lms/envs/content.py
@@ -2,6 +2,11 @@
 These are debug machines used for content creators, so they're kind of a cross
 between dev machines and AWS machines.
 """
+
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 from .aws import *
 
 DEBUG = True
diff --git a/lms/envs/dev.py b/lms/envs/dev.py
index 488110655ee..9d7c0b3ac2e 100644
--- a/lms/envs/dev.py
+++ b/lms/envs/dev.py
@@ -7,6 +7,11 @@ sessions. Assumes structure:
         /mitx # The location of this repo
         /log  # Where we're going to write log files
 """
+
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 from .common import *
 from logsettings import get_logger_config
 
diff --git a/lms/envs/dev_edx4edx.py b/lms/envs/dev_edx4edx.py
index 2ebd24e68b9..c90f369bc61 100644
--- a/lms/envs/dev_edx4edx.py
+++ b/lms/envs/dev_edx4edx.py
@@ -8,6 +8,10 @@ sessions. Assumes structure:
         /log  # Where we're going to write log files
 """
 
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 import socket
 
 if 'eecs1' in socket.gethostname():
diff --git a/lms/envs/dev_ike.py b/lms/envs/dev_ike.py
index 639d1869893..3f54b11d1e4 100644
--- a/lms/envs/dev_ike.py
+++ b/lms/envs/dev_ike.py
@@ -7,6 +7,11 @@ sessions. Assumes structure:
         /mitx # The location of this repo
         /log  # Where we're going to write log files
 """
+
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 from .common import *
 from logsettings import get_logger_config
 from .dev import *
diff --git a/lms/envs/dev_int.py b/lms/envs/dev_int.py
index 21c52c8abc9..34921205a6d 100644
--- a/lms/envs/dev_int.py
+++ b/lms/envs/dev_int.py
@@ -9,6 +9,11 @@ following domains to 127.0.0.1 in your /etc/hosts file:
 Note that OS X has a bug where using *.local domains is excruciatingly slow, so
 use *.dev domains instead for local testing.
 """
+
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 from .dev import *
 
 MITX_FEATURES['SUBDOMAIN_COURSE_LISTINGS'] = True
diff --git a/lms/envs/dev_mongo.py b/lms/envs/dev_mongo.py
index 6af0a429bb7..dfbf473b45f 100644
--- a/lms/envs/dev_mongo.py
+++ b/lms/envs/dev_mongo.py
@@ -1,6 +1,11 @@
 """
 This config file runs the dev environment, but with mongo as the datastore
 """
+
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 from .dev import *
 
 GITHUB_REPO_ROOT = ENV_ROOT / "data"
diff --git a/lms/envs/devgroups/courses.py b/lms/envs/devgroups/courses.py
index c44717c451b..1a7ff58f084 100644
--- a/lms/envs/devgroups/courses.py
+++ b/lms/envs/devgroups/courses.py
@@ -1,3 +1,8 @@
+
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 from ..dev import *
 
 CLASSES_TO_DBS = {
diff --git a/lms/envs/devgroups/h_cs50.py b/lms/envs/devgroups/h_cs50.py
index 9643c33d358..21c959f5ce6 100644
--- a/lms/envs/devgroups/h_cs50.py
+++ b/lms/envs/devgroups/h_cs50.py
@@ -1,3 +1,8 @@
+
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 from .courses import *
 
 DATABASES = course_db_for('HarvardX/CS50x/2012')
diff --git a/lms/envs/devgroups/m_6002.py b/lms/envs/devgroups/m_6002.py
index 411e2bcc3c8..d3c10fcd04e 100644
--- a/lms/envs/devgroups/m_6002.py
+++ b/lms/envs/devgroups/m_6002.py
@@ -1,3 +1,8 @@
+
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 from .courses import *
 
 DATABASES = course_db_for('MITx/6.002x/2012_Fall')
diff --git a/lms/envs/devgroups/portal.py b/lms/envs/devgroups/portal.py
index 35808d56fad..8e4635cc664 100644
--- a/lms/envs/devgroups/portal.py
+++ b/lms/envs/devgroups/portal.py
@@ -2,6 +2,11 @@
 Note that for this to work at all, you must have memcached running (or you won't
 get shared sessions)
 """
+
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 from courses import *
 
 # Move this to a shared file later:
diff --git a/lms/envs/devplus.py b/lms/envs/devplus.py
index ea6590291c7..bfd0788165d 100644
--- a/lms/envs/devplus.py
+++ b/lms/envs/devplus.py
@@ -13,6 +13,11 @@ Dir structure:
         /log  # Where we're going to write log files
 
 """
+
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 from .dev import *
 
 WIKI_ENABLED = True
diff --git a/lms/envs/discussionsettings.py b/lms/envs/discussionsettings.py
index f13680a7feb..1ac4c23af8f 100644
--- a/lms/envs/discussionsettings.py
+++ b/lms/envs/discussionsettings.py
@@ -1 +1,5 @@
+
+# We intentionally define variables that aren't used
+# pylint: disable=W0614
+
 DISCUSSION_ALLOWED_UPLOAD_FILE_TYPES = ('.jpg', '.jpeg', '.gif', '.bmp', '.png', '.tiff')
diff --git a/lms/envs/edx4edx_aws.py b/lms/envs/edx4edx_aws.py
index b82048824fb..247fa866bc7 100644
--- a/lms/envs/edx4edx_aws.py
+++ b/lms/envs/edx4edx_aws.py
@@ -1,3 +1,7 @@
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 # Settings for edx4edx production instance
 from .aws import *
 COURSE_NAME = "edx4edx"
diff --git a/lms/envs/jasmine.py b/lms/envs/jasmine.py
index ba4fcc52618..2c30bc7de76 100644
--- a/lms/envs/jasmine.py
+++ b/lms/envs/jasmine.py
@@ -2,6 +2,10 @@
 This configuration is used for running jasmine tests
 """
 
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 from .test import *
 from logsettings import get_logger_config
 
diff --git a/lms/envs/static.py b/lms/envs/static.py
index 23e735c7470..260153e6231 100644
--- a/lms/envs/static.py
+++ b/lms/envs/static.py
@@ -7,6 +7,11 @@ sessions. Assumes structure:
         /mitx # The location of this repo
         /log  # Where we're going to write log files
 """
+
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 from .common import *
 from logsettings import get_logger_config
 
diff --git a/lms/envs/test.py b/lms/envs/test.py
index b8782ccd755..6691d50106e 100644
--- a/lms/envs/test.py
+++ b/lms/envs/test.py
@@ -7,6 +7,11 @@ sessions. Assumes structure:
         /mitx # The location of this repo
         /log  # Where we're going to write log files
 """
+
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 from .common import *
 import os
 from path import path
diff --git a/lms/envs/test_ike.py b/lms/envs/test_ike.py
index 907b7eeadfd..46f7df211c8 100644
--- a/lms/envs/test_ike.py
+++ b/lms/envs/test_ike.py
@@ -7,6 +7,11 @@ sessions. Assumes structure:
         /mitx # The location of this repo
         /log  # Where we're going to write log files
 """
+
+# We intentionally define lots of variables that aren't used, and
+# want to import all variables from base settings files
+# pylint: disable=W0401, W0614
+
 from .common import *
 from logsettings import get_logger_config
 import os
diff --git a/.pylintrc b/pylintrc
similarity index 100%
rename from .pylintrc
rename to pylintrc
diff --git a/rakefiles/quality.rake b/rakefiles/quality.rake
index 00ce627ac52..927f765eb5e 100644
--- a/rakefiles/quality.rake
+++ b/rakefiles/quality.rake
@@ -1,3 +1,20 @@
+def run_pylint(system, report_dir, flags='')
+    apps = Dir["#{system}", "#{system}/djangoapps/*", "#{system}/lib/*"].map do |app|
+        File.basename(app)
+    end.select do |app|
+        app !=~ /.pyc$/
+    end.map do |app|
+        if app =~ /.py$/
+            app.gsub('.py', '')
+        else
+            app
+        end
+    end
+
+    pythonpath_prefix = "PYTHONPATH=#{system}:#{system}/djangoapps:#{system}/lib:common/djangoapps:common/lib"
+    sh("#{pythonpath_prefix} pylint #{flags} -f parseable #{apps.join(' ')} | tee #{report_dir}/pylint.report")
+end
+
 
 [:lms, :cms, :common].each do |system|
     report_dir = report_dir_path(system)
@@ -11,21 +28,18 @@
 
     desc "Run pylint on all #{system} code"
     task "pylint_#{system}" => [report_dir, :install_python_prereqs] do
-        apps = Dir["#{system}/*.py", "#{system}/djangoapps/*", "#{system}/lib/*"].map do |app|
-            File.basename(app)
-        end.select do |app|
-            app !=~ /.pyc$/
-        end.map do |app|
-            if app =~ /.py$/
-                app.gsub('.py', '')
-            else
-                app
-            end
+        run_pylint(system, report_dir)
+    end
+    namespace "pylint_#{system}" do
+        desc "Run pylint checking for errors only, and aborting if there are any"
+        task :errors do
+            run_pylint(system, report_dir, '-E')
         end
-
-        pythonpath_prefix = "PYTHONPATH=#{system}:#{system}/djangoapps:#{system}/lib:common/djangoapps:common/lib"
-        sh("#{pythonpath_prefix} pylint --rcfile=.pylintrc -f parseable #{apps.join(' ')} | tee #{report_dir}/pylint.report")
     end
+    namespace :pylint do
+        task :errors => "pylint_#{system}:errors"
+    end
+
     task :pylint => "pylint_#{system}"
 
 end
\ No newline at end of file
-- 
GitLab