Skip to content

Commit e105260

Browse files
authored
[TEAMMATES#7433] Add lintspaces to enforce space-related rules (TEAMMATES#7434)
1 parent 8d041e8 commit e105260

File tree

354 files changed

+951
-1018
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

354 files changed

+951
-1018
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -336,4 +336,4 @@ This General Public License does not permit incorporating your program into
336336
proprietary programs. If your program is a subroutine library, you may
337337
consider it more useful to permit linking proprietary applications with the
338338
library. If this is what you want to do, use the GNU Lesser General
339-
Public License instead of this License.
339+
Public License instead of this License.

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ install:
2424
- npm install
2525

2626
build_script:
27-
- gradlew.bat createConfigs testClasses
27+
- gradlew.bat createConfigs testClasses
2828

2929
test_script:
3030
- npm run build

docs/design.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Represented by these classes:
125125

126126
### Policies
127127

128-
General:
128+
General:
129129
+ Null values should **not** be used as parameters to this API, except when following the KeepExisting policy (explained later).
130130

131131
Access control:
@@ -139,7 +139,7 @@ API for creating entities:
139139

140140
API for retrieving entities:
141141
+ Attempting to retrieve objects using `null` parameters: Causes an assertion failure.
142-
+ Entity not found:
142+
+ Entity not found:
143143
- Returns `null` if the target entity not found. This way, read operations can be used easily for checking the existence of an entity.
144144
- Throws `EntityDoesNotExistsExeption` if a parent entity of a target entity is not found e.g., trying to list students of a non-existent course.
145145

@@ -153,7 +153,7 @@ API for updating entities:
153153
API for deleting entities:
154154
+ `Null` parameters: Not expected. Results in assertion failure.
155155
+ FailDeleteSilentlyPolicy: In general, delete operation do not throw exceptions if the target entity does not exist. Instead, it logs a warning. This is because if it does not exist, it is as good as deleted.
156-
+ Cascade policy: When a parent entity is deleted, entities that have referential integrity with the deleted entity should also be deleted.
156+
+ Cascade policy: When a parent entity is deleted, entities that have referential integrity with the deleted entity should also be deleted.
157157
Refer to the API for the cascade logic.
158158

159159
## Storage Component
@@ -187,12 +187,12 @@ Represented by the `*Db` classes. These classes act as the bridge to the GAE Dat
187187

188188
### Policies
189189

190-
Add and Delete operations try to wait until data is persisted in the datastore before returning. This is not enough to compensate for eventual consistency involving multiple servers in the GAE production enviornment. However, it is expected to avoid test failures caused by eventual consistency in dev server and reduce such problems in the live server.
191-
Note: 'Eventual consistency' here means it takes some time for a database operation to propagate across all serves of the Google's distributed datastore. As a result, the data may be in an inconsistent states for short periods of time although things should become consistent 'eventually'. For example, an object we deleted may appear to still exist for a short while.
190+
Add and Delete operations try to wait until data is persisted in the datastore before returning. This is not enough to compensate for eventual consistency involving multiple servers in the GAE production enviornment. However, it is expected to avoid test failures caused by eventual consistency in dev server and reduce such problems in the live server.
191+
Note: 'Eventual consistency' here means it takes some time for a database operation to propagate across all serves of the Google's distributed datastore. As a result, the data may be in an inconsistent states for short periods of time although things should become consistent 'eventually'. For example, an object we deleted may appear to still exist for a short while.
192192

193-
Implementation of Transaction Control has been decided against due to limitations of GAE environment and the nature of our data schema. Please see [TEAMMATES Decision Analysis](https://docs.google.com/document/pub?id=1o6pNPshCp9S31ymHY0beQ1DVafDa1_k_k7bpxZo5GeU&embedded=true) document for more information.
193+
Implementation of Transaction Control has been decided against due to limitations of GAE environment and the nature of our data schema. Please see [TEAMMATES Decision Analysis](https://docs.google.com/document/pub?id=1o6pNPshCp9S31ymHY0beQ1DVafDa1_k_k7bpxZo5GeU&embedded=true) document for more information.
194194

195-
General:
195+
General:
196196
+ If `Null` is passed as a parameter, the corresponding value is **NOT** modified, as per the KeepExistingPolicy that was previously mentioned.
197197

198198
API for creating:

docs/godmode.md

+4-9
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,20 @@ Typically browser tests involve comparing the source of the webpage to an existi
66

77
GodMode has been extended and now is also able to create and update *expected* source files for email content tests. It works with the same underlying principle as the one for browser tests.
88

9-
109
## How does GodMode work?
1110

1211
The essential idea is to reverse the process of testing. We use the _actual_ source of the webpage to overwrite the _expected_ source in the test. To remove redundancy, even if GodMode is enabled, this overwriting procedure only happens when a test fails during the test run. Finally before the changes are committed, a *manual* (by the developer) verification to ensure only the intended changes have occurred is mandatory.
1312

14-
1513
## How do we use GodMode?
1614

17-
GodMode can be activated in two different ways.
15+
GodMode can be activated in two different ways.
1816

1917
1. If we want to execute arbitrary tests using GodMode, then update `BaseUiTestCase` class (or `EmailGeneratorTest` class if testing email content) and set `isGodModeEnabled = true` at the top of the class implementation. Now all test runs would have GodMode enabled. Please remember to set it back to false when done.
2018

2119
2. If we want to run a particular test suite using GodMode, then go to `Run -> Run Configurations` and update the appropriate one with the `-Dgodmode=true` VM argument. Please remember to remove the argument before committing the changes
2220

2321
Note: The first option encompasses the functionality of the second. By updating the BaseUiTestCase and running the intended test suite, we achieve the second option's effect.
2422

25-
2623
## When do we use GodMode?
2724

2825
GodMode is typically used in the following two situations:
@@ -38,7 +35,7 @@ studentHomePage.verifyHtmlMainContent("/studentHomeTypicalHTML.html");
3835

3936
Here are three possible situations and the corresponding behaviours of GodMode when the test is executed with GodMode enabled:
4037

41-
1. If `studentHomeTypicalHTML.html` exists and has the correct content, GodMode will not make any updates to the source file.
38+
1. If `studentHomeTypicalHTML.html` exists and has the correct content, GodMode will not make any updates to the source file.
4239

4340
2. If `studentHomeTypicalHTML.html` exists but has the wrong content, GodMode will update the source file with the correct content. The effect of this is that the test case will pass subsequent test runs with/without GodMode enabled.
4441

@@ -49,7 +46,6 @@ The same idea applies to email content test:
4946
EmailChecker.verifyEmailContent(email, recipient, subject, "/studentCourseJoinEmail.html");
5047
```
5148

52-
5349
## Best Practices
5450

5551
1. Ensure that GodMode is only used when necessary, that is when there are new test cases being created or when an update to the existing tests is foreseen.
@@ -58,8 +54,7 @@ EmailChecker.verifyEmailContent(email, recipient, subject, "/studentCourseJoinEm
5854

5955
3. Please confirm that all the changes made by GodMode are EXPECTED. If any unexpected changes are made, please ask for assistance in the issue tracker or create a new issue if need be.
6056

61-
4. After all the necessary changes have been made, run the test suite once without GodMode enabled to ensure that the tests pass without GodMode.
62-
57+
4. After all the necessary changes have been made, run the test suite once without GodMode enabled to ensure that the tests pass without GodMode.
6358

6459
## Final Notes
6560

@@ -87,4 +82,4 @@ to
8782
</div>
8883
```
8984

90-
Happy Testing!
85+
Happy Testing!

docs/ide-usage.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ The following plugins are needed:
7171
* HTML: `Web → HTML Files → Editor → Indent using spaces`.
7272
* CSS: `Web → CSS Files → Editor → Indent using spaces`.
7373
* XML: `XML → XML Files → Editor → Indent using spaces`.
74-
* Validation:
74+
* Validation:
7575
* We do not validate HTML, JSP, and XML. `Validation` → uncheck the `Build` option for `HTML Syntax Validator`, `JSP Content Validator`, `JSP Syntax Validator`, and `XML Validator`.
7676
* Disable JavaScript validation for `node_modules` folder. `Validation` → click the `...` settings button for `JavaScript Validation` → if `Exclude Group` is not already in the list then click `Add Exclude Group...``Exclude Group``Add Rule...``Folder or file name``Next``Browse Folder...` → navigate to the `node_modules` folder and confirm → `Finish`.
7777

docs/settingUp.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ More information can be found at [this documentation](https://help.github.com/ar
4343
1. Run this command to download the correct version Google App Engine SDK as used in the project:
4444
```sh
4545
./gradlew appengineDownloadSdk
46-
```
46+
```
4747
**Verification:** Check your Gradle folder (the directory can be found with the command `./gradlew printUserHomeDir`). A folder named appengine-sdk` should be present.
48-
48+
4949
1. Run this command to download the necessary tools for JavaScript development:
5050
```sh
5151
npm install

docs/troubleshooting-guide.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Note that some of the screenshots might be outdated, but the instructions will r
2020
**REASON**: This happens because Eclipse is only aware of JRE, not JDK (Compiling JSP requires the JDK).
2121

2222
Go to `Window → Preferences → Java → Installed JREs`. You will note that a JRE path is the one selected, not a JDK path.
23-
23+
2424
**SOLUTION**: To fix this, Click `Add → Standard VM`, then for the JRE Path enter the path of the JRE folder inside your JDK installation folder, e.g. `C:/jdk1.7/jre`. Now you should see all of the JARs added to the library section.
2525

2626
* **ERROR**: When trying to deploy, Eclipse complains "... Cannot get the System Java Compiler. Please use a JDK, not a JRE.".
@@ -106,7 +106,7 @@ Furthermore, you might see tags such as `${test.student1}` and `${version}` in s
106106
* **ERROR**: After deploying on the staging server, you get an error related to "Unsupported major.minor version ..." when trying to access pages of the staged app.
107107

108108
**REASON**: This can happen if you have Java 8 installed and Eclipse uses Java 8 during deployment, even if you have already configured the project to use Java 7.
109-
109+
110110
**SOLUTION**: Refer to [this page](http://java.wildstartech.com/Java-Platform-Standard-Edition/mac-os-x-java-development/how-to-configure-eclipse-to-run-with-java-7-when-java-8-is-installed) to learn how to modify `eclipse.ini` to use Java 7 by default.
111111

112112
* **ERROR**: A handful of failed test cases (< 10).
@@ -140,9 +140,9 @@ Furthermore, you might see tags such as `${test.student1}` and `${version}` in s
140140
**SOLUTION**: Add `-Djava.io.tmpdir=/path/to/teammates/tmp` for the tests' run configurations. The "tmp" folder in the specified directory needs to be created before running the tests.
141141

142142
* **ERROR (on IntelliJ)**: Error message in console when running dev server : `Cannot start process, the working directory '{project home directory}/build/libs/exploded/teammates.war' does not exist` or `Could not locate /.../appengine-web.xml`.
143-
143+
144144
**SOLUTION**: The path to the exploded application may be configured wrongly. Go to `File → Project Structure...`. Under `Under Artifacts → Gradle : <your-project-name>.war (exploded)`, change `Output directory` to `{path to repo}/build/exploded-app`, which contains `appengine-web.xml`.
145-
145+
146146
## Submitting help request
147147

148148
If none of the items in this guide helps with the problem you face, you can [post in the issue tracker](https://github.com/TEAMMATES/teammates/issues/new) to request for help.

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"eslint-config-airbnb-base": "11.1.1",
77
"eslint-plugin-import": "2.2.0",
88
"eslint-plugin-json": "1.2.0",
9+
"lintspaces-cli": "0.6.0",
910
"stylelint": "7.9.0"
1011
},
1112
"babel": {
@@ -25,6 +26,7 @@
2526
"lint:test": "eslint src/main/webapp/dev -c static-analysis/teammates-eslint.yml --ext .es6",
2627
"lint:json": "eslint src/main/webapp/js/*.json src/main/resources/*.json src/test/resources/data/*.json -c static-analysis/teammates-eslint-json.yml",
2728
"lint:css": "stylelint src/main/webapp/stylesheets/*.css --config static-analysis/teammates-stylelint.yml",
28-
"lint": "npm run lint:src && npm run lint:test && npm run lint:json && npm run lint:css"
29+
"lint:spaces": "lintspaces -n -t -d spaces -l 1 -. 'src/**/*.jsp' 'src/**/*.tag' 'src/main/**/*.html' 'src/**/*.xml' 'src/**/*.json' 'src/**/*.css' 'src/**/*.java' 'src/**/*.es6' 'src/**/*.properties' '*.yml' '*.gradle' 'static-analysis/*.*ml'",
30+
"lint": "npm run lint:src && npm run lint:test && npm run lint:json && npm run lint:css && npm run lint:spaces"
2931
}
3032
}

src/client/java/teammates/client/scripts/scalabilitytests/InstructorCourseEnrollPageDataGenerator.java

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import teammates.test.driver.FileHelper;
1111

12-
1312
/**
1413
* Generates test data for InstructorCourseEnrollPageScaleTest.
1514
*/

src/main/java/teammates/common/util/StringHelper.java

-1
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,6 @@ public static String removeNonAscii(String text) {
555555
return text.replaceAll("[^\\x00-\\x7F]", "");
556556
}
557557

558-
559558
/**
560559
* Returns a new String composed of copies of the String elements joined together
561560
* with a copy of the specified delimiter.

src/main/java/teammates/ui/automated/FeedbackResponseAdjustmentWorkerAction.java

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import teammates.common.util.LogMessageGenerator;
1616
import teammates.common.util.Logger;
1717

18-
1918
/**
2019
* Task queue worker action: adjusts feedback responses in the database due to
2120
* change in student enrollment details of a course.

src/main/resources/InstructorSampleData.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2783,4 +2783,4 @@
27832783
}
27842784
},
27852785
"profiles": {}
2786-
}
2786+
}

src/main/resources/META-INF/persistence.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
</properties>
1212
</persistence-unit>
1313

14-
</persistence>
14+
</persistence>

src/main/resources/build.template.properties

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#-----------------------------------------------------------------------------
22
# This file contains some configuration values required using building
33
# and running of the app.
4-
# It should be placed in src\main\resources
4+
# It should be placed in src\main\resources
55
# Use '\' to escape ':' e.g., http\://google.com
66
#-----------------------------------------------------------------------------
77

88
# This is the app url used in emails sent out by app.
9-
# For dev server, any URL would do.
9+
# For dev server, any URL would do.
1010
# For staging server, use the url of the app on remote server.
1111
# e.g. app.url=https\://teammates-john.appspot.com
1212
app.url=https\://teammates-john.appspot.com
@@ -17,9 +17,9 @@ app.url=https\://teammates-john.appspot.com
1717
# e.g. app.gcs.bucketname = teammates-michelle.appspot.com
1818
app.gcs.bucketname=teammates-john.appspot.com
1919

20-
# This is the key used by test driver to access backdoor.
21-
# It can be any random string you choose,
22-
# as long as it matches with test.backdoor.key in test.properties.
20+
# This is the key used by test driver to access backdoor.
21+
# It can be any random string you choose,
22+
# as long as it matches with test.backdoor.key in test.properties.
2323
# e.g. app.backdoor.key=lsfdieafoereojfe
2424

2525
app.backdoor.key=samplekey
@@ -33,12 +33,12 @@ app.encryption.key=5360b12f6a07af7be93437d215f72fca
3333
# This is the maximum time the app waits for a datastore operation to persist.
3434
# We use such a delay because of 'eventual consistency' nature of the datastore.
3535
# Increase the number if test cases fail due to persistency delays.
36-
# Value is in milliseconds
36+
# Value is in milliseconds
3737
app.persistence.checkduration=4000
3838

3939
# This is the email address to report runtime error not handled
4040
# by the system, i.e. AssertionFailure and other unchecked exceptions.
41-
# This should be an email you check. e.g., email of the app admin.
41+
# This should be an email you check. e.g., email of the app admin.
4242
app.crashreport.email = app_admin@gmail.com
4343

4444
# This is the url to display as a message of the day to a student.
@@ -66,17 +66,16 @@ app.email.replyto = teammates@comp.nus.edu.sg
6666
app.email.service = javamail
6767

6868
# Sendgrid API key for sending emails
69-
app.sendgrid.apikey =
69+
app.sendgrid.apikey =
7070

7171
# Mailgun API key for sending emails
72-
app.mailgun.apikey =
72+
app.mailgun.apikey =
7373

7474
# Mailgun domain name for sending emails
75-
app.mailgun.domainname =
75+
app.mailgun.domainname =
7676

7777
# Mailjet API key for sending emails
78-
app.mailjet.apikey =
78+
app.mailjet.apikey =
7979

8080
# Mailjet secret key for sending emails
81-
app.mailjet.secretkey =
82-
81+
app.mailjet.secretkey =

src/main/resources/feedbackQuestionAdditionalInfoTemplate.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
<a href="javascript:;" id="questionAdditionalInfoButton-${questionNumber}-${additionalInfoId}" class="color_gray" onclick="toggleAdditionalQuestionInfo('${questionNumber}-${additionalInfoId}')" data-more="${more}" data-less="${less}">${more}</a>
33
<br>
44
<span id="questionAdditionalInfo-${questionNumber}-${additionalInfoId}" style="display:none;">${questionAdditionalInfo}</span>
5-
</span>
5+
</span>

src/main/resources/feedbackQuestionConstSumEditFormOptionFragment.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
id="${Const.ParamsNames.FEEDBACK_QUESTION_CONSTSUMOPTION}-${i}-${questionNumber}"
66
class="constSumOptionTextBox" value="${constSumOptionValue}">
77
<span class="input-group-btn">
8-
<button class="btn btn-default removeOptionLink" type="button" id="constSumRemoveOptionLink"
8+
<button class="btn btn-default removeOptionLink" type="button" id="constSumRemoveOptionLink"
99
onclick="removeConstSumOption(${i},${questionNumber})"
1010
style="display:none" tabindex="-1">
1111
<span class="glyphicon glyphicon-remove">
1212
</span>
1313
</button>
1414
</span>
1515
</div>
16-
</div>
16+
</div>

src/main/resources/feedbackQuestionConstSumResultStatsOptionFragment.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
${pointsReceived}
77
</td>
88
<td>
9-
${totalPoints}
9+
${totalPoints}
1010
</td>
1111
<td>
1212
${averagePoints}
1313
</td>
14-
</tr>
14+
</tr>

src/main/resources/feedbackQuestionConstSumResultStatsRecipientFragment.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
${pointsReceived}
1010
</td>
1111
<td>
12-
${totalPoints}
12+
${totalPoints}
1313
</td>
1414
<td>
1515
${averagePoints}
1616
</td>
17-
</tr>
17+
</tr>

src/main/resources/feedbackQuestionConstSumResultStatsRecipientTemplate.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@
2929
</table>
3030
</div>
3131
</div>
32-
</div>
32+
</div>

src/main/resources/feedbackQuestionConstSumResultStatsTemplate.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@
3535
</table>
3636
</div>
3737
</div>
38-
</div>
38+
</div>

src/main/resources/feedbackQuestionContribAdditionalInfoTemplate.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
<a href="javascript:;" id="questionAdditionalInfoButton-${questionNumber}-${additionalInfoId}" class="small link-in-dark-bg" onclick="toggleAdditionalQuestionInfo('${questionNumber}-${additionalInfoId}')" data-more="${more}" data-less="${less}">${more}</a>
33
<br>
44
<span id="questionAdditionalInfo-${questionNumber}-${additionalInfoId}" style="display:none;">${questionAdditionalInfo}</span>
5-
</span>
5+
</span>

src/main/resources/feedbackQuestionContribEditFormTemplate.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
<span style="margin-left: 5px; font-weight: bold;">Allow response giver to select 'Not Sure' as the answer</span>
77
</div>
88
</div>
9-
</div>
9+
</div>
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<tr>
22
<td>${studentTeam}</td>
3-
<td id="${Const.ParamsNames.STUDENT_NAME}">
3+
<td id="${Const.ParamsNames.STUDENT_NAME}">
44
${studentName}
55
</td>
66
<td>${CC}</td>
77
<td>${PC}</td>
88
<td>${Diff}</td>
99
<td>${RR}</td>
10-
</tr>
10+
</tr>

0 commit comments

Comments
 (0)