diff options
-rw-r--r-- | .gitignore | 6 | ||||
-rw-r--r-- | .idea/misc.xml | 7 | ||||
-rw-r--r-- | .idea/term-project-cohwille-jmccaul3-mfoiani-rhunt2.iml | 51 | ||||
-rw-r--r-- | config/cs32_checks.xml | 166 | ||||
-rw-r--r-- | config/cs32_intellij_checks.xml | 166 | ||||
-rw-r--r-- | data/README.md | 4 | ||||
-rw-r--r-- | pom.xml | 318 | ||||
-rwxr-xr-x | run | 49 | ||||
-rw-r--r-- | src/main/java/edu/brown/cs/student/stars/Main.java | 62 | ||||
-rw-r--r-- | tests/README.md | 4 |
10 files changed, 829 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0fb7610 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +target/ +.mvn-classpath +.classpath +.idea/ +**.DS_Store** +maps.sqlite3
\ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 1763e15..d460235 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> + <component name="MavenProjectsManager"> + <option name="originalFiles"> + <list> + <option value="$PROJECT_DIR$/pom.xml" /> + </list> + </option> + </component> <component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK"> <output url="file://$PROJECT_DIR$/out" /> </component> diff --git a/.idea/term-project-cohwille-jmccaul3-mfoiani-rhunt2.iml b/.idea/term-project-cohwille-jmccaul3-mfoiani-rhunt2.iml index d6ebd48..e5e71fc 100644 --- a/.idea/term-project-cohwille-jmccaul3-mfoiani-rhunt2.iml +++ b/.idea/term-project-cohwille-jmccaul3-mfoiani-rhunt2.iml @@ -1,9 +1,52 @@ <?xml version="1.0" encoding="UTF-8"?> -<module type="JAVA_MODULE" version="4"> - <component name="NewModuleRootManager" inherit-compiler-output="true"> - <exclude-output /> - <content url="file://$MODULE_DIR$" /> +<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> + <component name="CheckStyle-IDEA-Module"> + <option name="configuration"> + <map /> + </option> + </component> + <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_11"> + <output url="file://$MODULE_DIR$/target/classes" /> + <output-test url="file://$MODULE_DIR$/target/test-classes" /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> + <excludeFolder url="file://$MODULE_DIR$/target" /> + </content> <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="library" name="Maven: net.sf.jopt-simple:jopt-simple:6.0-alpha-3" level="project" /> + <orderEntry type="library" name="Maven: junit:junit:4.13" level="project" /> + <orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" /> + <orderEntry type="library" name="Maven: org.hamcrest:hamcrest-all:1.3" level="project" /> + <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:2.0.0-alpha1" level="project" /> + <orderEntry type="library" name="Maven: org.slf4j:slf4j-jdk14:2.0.0-alpha1" level="project" /> + <orderEntry type="library" name="Maven: com.google.guava:guava:28.2-jre" level="project" /> + <orderEntry type="library" name="Maven: com.google.guava:failureaccess:1.0.1" level="project" /> + <orderEntry type="library" name="Maven: com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava" level="project" /> + <orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" /> + <orderEntry type="library" name="Maven: org.checkerframework:checker-qual:2.10.0" level="project" /> + <orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.3.4" level="project" /> + <orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.3" level="project" /> + <orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.6" level="project" /> + <orderEntry type="library" name="Maven: com.sparkjava:spark-core:2.9.1" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-server:9.4.18.v20190429" level="project" /> + <orderEntry type="library" name="Maven: javax.servlet:javax.servlet-api:3.1.0" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-http:9.4.18.v20190429" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-util:9.4.18.v20190429" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-io:9.4.18.v20190429" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-webapp:9.4.18.v20190429" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-xml:9.4.18.v20190429" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-servlet:9.4.18.v20190429" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-security:9.4.18.v20190429" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty.websocket:websocket-server:9.4.18.v20190429" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty.websocket:websocket-common:9.4.18.v20190429" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty.websocket:websocket-client:9.4.18.v20190429" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-client:9.4.18.v20190429" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty.websocket:websocket-servlet:9.4.18.v20190429" level="project" /> + <orderEntry type="library" name="Maven: org.eclipse.jetty.websocket:websocket-api:9.4.18.v20190429" level="project" /> + <orderEntry type="library" name="Maven: com.sparkjava:spark-template-freemarker:2.7.1" level="project" /> + <orderEntry type="library" name="Maven: org.freemarker:freemarker:2.3.26-incubating" level="project" /> + <orderEntry type="library" name="Maven: org.xerial:sqlite-jdbc:3.30.1" level="project" /> </component> </module>
\ No newline at end of file diff --git a/config/cs32_checks.xml b/config/cs32_checks.xml new file mode 100644 index 0000000..c0805f9 --- /dev/null +++ b/config/cs32_checks.xml @@ -0,0 +1,166 @@ +<?xml version="1.0"?> +<!DOCTYPE module PUBLIC + "-//Puppy Crawl//DTD Check Configuration 1.3//EN" + "https://checkstyle.org/dtds/configuration_1_3.dtd"> + +<!-- + Checkstyle configuration that checks the coding conventions from: + - the Java Language Specification at + http://java.sun.com/docs/books/jls/second_edition/html/index.html + - the Sun Code Conventions at http://java.sun.com/docs/codeconv/ + - the Javadoc guidelines at + http://java.sun.com/j2se/javadoc/writingdoccomments/index.html + - the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html + - some best practices + - changes for cs32 are marked CS32 + Checkstyle is very configurable. Be sure to read the documentation at + http://checkstyle.sf.net (or in your downloaded distribution). + Most Checks are configurable, be sure to consult the documentation. + To completely disable a check, just comment it out or delete it from the file. + Finally, it is worth reading the documentation. +--> + +<module name="Checker"> + <!-- + If you set the basedir property below, then all reported file + names will be relative to the specified directory. See + http://checkstyle.sourceforge.net/5.x/config.html#Checker + <property name="basedir" value="${basedir}"/> + --> + + <!-- Checks that a package-info.java file exists for each package. --> + <!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage --> + <!-- <module name="JavadocPackage"/> --> + + <!-- Checks whether files end with a new line. --> + <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile --> + <module name="NewlineAtEndOfFile"/> + + <!-- Checks that property files contain the same keys. --> + <!-- See http://checkstyle.sf.net/config_misc.html#Translation --> + <module name="Translation"/> + + <!-- Checks for Size Violations. --> + <!-- See http://checkstyle.sf.net/config_sizes.html --> + <module name="FileLength"/> + + <!-- Checks for whitespace --> + <!-- See http://checkstyle.sf.net/config_whitespace.html --> + <module name="FileTabCharacter"/> + + <!-- Miscellaneous other checks. --> + <!-- See http://checkstyle.sf.net/config_misc.html --> + <module name="RegexpSingleline"> + <property name="format" value="\s+$"/> + <property name="minimum" value="0"/> + <property name="maximum" value="0"/> + <property name="message" value="Line has trailing spaces."/> + </module> + + <module name="TreeWalker"> + + <!-- Checks for Javadoc comments. --> + <!-- See http://checkstyle.sf.net/config_javadoc.html --> + <module name="JavadocMethod"> + <property name="scope" value="public"/> + </module> + <module name="JavadocType"/> + <!-- <module name="JavadocVariable"/> --> + <module name="JavadocStyle"/> + + <!-- Checks for Naming Conventions. --> + <!-- See http://checkstyle.sf.net/config_naming.html --> + <module name="ConstantName"/> + <module name="LocalFinalVariableName"/> + <module name="LocalVariableName"/> + <module name="MemberName"/> + <module name="MethodName"/> + <module name="PackageName"/> + <module name="ParameterName"/> + <module name="StaticVariableName"/> + <module name="TypeName"/> + + <!-- Checks for imports --> + <!-- See http://checkstyle.sf.net/config_import.html --> + <module name="AvoidStarImport"/> + <module name="IllegalImport"/> <!-- defaults to sun.* packages --> + <module name="RedundantImport"/> + <module name="UnusedImports"/> + + <!-- Checks for Size Violations. --> + <!-- See http://checkstyle.sf.net/config_sizes.html --> + <module name="MethodLength"/> + <module name="ParameterNumber"/> + <module name="LineLength"> + <property name="max" value="100"/> + <property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/> + </module> + + <!-- Checks for whitespace --> + <!-- See http://checkstyle.sf.net/config_whitespace.html --> + <module name="EmptyForIteratorPad"/> + <module name="GenericWhitespace"/> + <module name="MethodParamPad"/> + <module name="NoWhitespaceAfter"/> + <module name="NoWhitespaceBefore"/> + <module name="OperatorWrap"/> + <module name="ParenPad"/> + <module name="TypecastParenPad"/> + <module name="WhitespaceAfter"/> + <module name="WhitespaceAround"/> + + <!-- Modifier Checks --> + <!-- See http://checkstyle.sf.net/config_modifiers.html --> + <module name="ModifierOrder"/> + <module name="RedundantModifier"/> + + <!-- Checks for blocks. You know, those {}'s --> + <!-- See http://checkstyle.sf.net/config_blocks.html --> + <module name="AvoidNestedBlocks"/> + <module name="EmptyBlock"/> + <module name="LeftCurly"/> + <module name="NeedBraces"/> + <module name="RightCurly"/> + + <!-- Checks for common coding problems --> + <!-- See http://checkstyle.sf.net/config_coding.html --> + <!-- CS32 <module name="AvoidInlineConditionals"/> --> + <module name="EmptyStatement"/> + <module name="EqualsHashCode"/> + <module name="HiddenField"> + <property name="ignoreConstructorParameter" value="true"/> + <property name="ignoreSetter" value="true"/> + </module> + <module name="IllegalInstantiation"/> + <module name="InnerAssignment"/> + <module name="MagicNumber"> + <property name="ignoreNumbers" value="-1,0,1,2,3,4,5,6,200,400,401,403,404,405,500,501"/> + </module> + <module name="MissingSwitchDefault"/> + <module name="SimplifyBooleanExpression"/> + <module name="SimplifyBooleanReturn"/> + + <!-- Checks for class design --> + <!-- See http://checkstyle.sf.net/config_design.html --> + <!-- CS32 <module name="DesignForExtension"/> --> + <module name="FinalClass"/> + <module name="HideUtilityClassConstructor"/> + <module name="InterfaceIsType"/> + <module name="VisibilityModifier"/> + + + <!-- Miscellaneous other checks. --> + <!-- See http://checkstyle.sf.net/config_misc.html --> + <module name="ArrayTypeStyle"/> + <!-- <module name="FinalParameters"/> --> + <module name="TodoComment"/> + <module name="UpperEll"/> + <module name="Indentation"> + <property name="basicOffset" value="2"/> + <property name="caseIndent" value="2"/> + <property name="throwsIndent" value="2"/> + </module> + + </module> + +</module>
\ No newline at end of file diff --git a/config/cs32_intellij_checks.xml b/config/cs32_intellij_checks.xml new file mode 100644 index 0000000..69d8e0d --- /dev/null +++ b/config/cs32_intellij_checks.xml @@ -0,0 +1,166 @@ +<?xml version="1.0"?> +<!DOCTYPE module PUBLIC + "-//Puppy Crawl//DTD Check Configuration 1.3//EN" + "https://checkstyle.org/dtds/configuration_1_3.dtd"> + +<!-- + Checkstyle configuration that checks the coding conventions from: + - the Java Language Specification at + http://java.sun.com/docs/books/jls/second_edition/html/index.html + - the Sun Code Conventions at http://java.sun.com/docs/codeconv/ + - the Javadoc guidelines at + http://java.sun.com/j2se/javadoc/writingdoccomments/index.html + - the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html + - some best practices + - changes for cs32 are marked CS32 + Checkstyle is very configurable. Be sure to read the documentation at + http://checkstyle.sf.net (or in your downloaded distribution). + Most Checks are configurable, be sure to consult the documentation. + To completely disable a check, just comment it out or delete it from the file. + Finally, it is worth reading the documentation. +--> + +<module name="Checker"> + <!-- + If you set the basedir property below, then all reported file + names will be relative to the specified directory. See + http://checkstyle.sourceforge.net/5.x/config.html#Checker + <property name="basedir" value="${basedir}"/> + --> + + <!-- Checks that a package-info.java file exists for each package. --> + <!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage --> + <!-- <module name="JavadocPackage"/> --> + + <!-- Checks whether files end with a new line. --> + <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile --> + <module name="NewlineAtEndOfFile"/> + + <!-- Checks that property files contain the same keys. --> + <!-- See http://checkstyle.sf.net/config_misc.html#Translation --> + <module name="Translation"/> + + <!-- Checks for Size Violations. --> + <!-- See http://checkstyle.sf.net/config_sizes.html --> + <module name="FileLength"/> + <module name="LineLength"> + <property name="max" value="100"/> + <property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/> + </module> + + <!-- Checks for whitespace --> + <!-- See http://checkstyle.sf.net/config_whitespace.html --> + <module name="FileTabCharacter"/> + + <!-- Miscellaneous other checks. --> + <!-- See http://checkstyle.sf.net/config_misc.html --> + <module name="RegexpSingleline"> + <property name="format" value="\s+$"/> + <property name="minimum" value="0"/> + <property name="maximum" value="0"/> + <property name="message" value="Line has trailing spaces."/> + </module> + + <module name="TreeWalker"> + + <!-- Checks for Javadoc comments. --> + <!-- See http://checkstyle.sf.net/config_javadoc.html --> + <module name="JavadocMethod"> + <property name="scope" value="public"/> + </module> + <module name="JavadocType"/> + <!-- <module name="JavadocVariable"/> --> + <module name="JavadocStyle"/> + + <!-- Checks for Naming Conventions. --> + <!-- See http://checkstyle.sf.net/config_naming.html --> + <module name="ConstantName"/> + <module name="LocalFinalVariableName"/> + <module name="LocalVariableName"/> + <module name="MemberName"/> + <module name="MethodName"/> + <module name="PackageName"/> + <module name="ParameterName"/> + <module name="StaticVariableName"/> + <module name="TypeName"/> + + <!-- Checks for imports --> + <!-- See http://checkstyle.sf.net/config_import.html --> + <module name="AvoidStarImport"/> + <module name="IllegalImport"/> <!-- defaults to sun.* packages --> + <module name="RedundantImport"/> + <module name="UnusedImports"/> + + <!-- Checks for Size Violations. --> + <!-- See http://checkstyle.sf.net/config_sizes.html --> + <module name="MethodLength"/> + <module name="ParameterNumber"/> + + <!-- Checks for whitespace --> + <!-- See http://checkstyle.sf.net/config_whitespace.html --> + <module name="EmptyForIteratorPad"/> + <module name="GenericWhitespace"/> + <module name="MethodParamPad"/> + <module name="NoWhitespaceAfter"/> + <module name="NoWhitespaceBefore"/> + <module name="OperatorWrap"/> + <module name="ParenPad"/> + <module name="TypecastParenPad"/> + <module name="WhitespaceAfter"/> + <module name="WhitespaceAround"/> + + <!-- Modifier Checks --> + <!-- See http://checkstyle.sf.net/config_modifiers.html --> + <module name="ModifierOrder"/> + <module name="RedundantModifier"/> + + <!-- Checks for blocks. You know, those {}'s --> + <!-- See http://checkstyle.sf.net/config_blocks.html --> + <module name="AvoidNestedBlocks"/> + <module name="EmptyBlock"/> + <module name="LeftCurly"/> + <module name="NeedBraces"/> + <module name="RightCurly"/> + + <!-- Checks for common coding problems --> + <!-- See http://checkstyle.sf.net/config_coding.html --> + <!-- CS32 <module name="AvoidInlineConditionals"/> --> + <module name="EmptyStatement"/> + <module name="EqualsHashCode"/> + <module name="HiddenField"> + <property name="ignoreConstructorParameter" value="true"/> + <property name="ignoreSetter" value="true"/> + </module> + <module name="IllegalInstantiation"/> + <module name="InnerAssignment"/> + <module name="MagicNumber"> + <property name="ignoreNumbers" value="-1,0,1,2,3,4,5,6,200,400,401,403,404,405,500,501"/> + </module> + <module name="MissingSwitchDefault"/> + <module name="SimplifyBooleanExpression"/> + <module name="SimplifyBooleanReturn"/> + + <!-- Checks for class design --> + <!-- See http://checkstyle.sf.net/config_design.html --> + <!-- CS32 <module name="DesignForExtension"/> --> + <module name="FinalClass"/> + <module name="HideUtilityClassConstructor"/> + <module name="InterfaceIsType"/> + <module name="VisibilityModifier"/> + + + <!-- Miscellaneous other checks. --> + <!-- See http://checkstyle.sf.net/config_misc.html --> + <module name="ArrayTypeStyle"/> + <!-- <module name="FinalParameters"/> --> + <module name="TodoComment"/> + <module name="UpperEll"/> + <module name="Indentation"> + <property name="basicOffset" value="2"/> + <property name="caseIndent" value="2"/> + <property name="throwsIndent" value="2"/> + </module> + + </module> + +</module>
\ No newline at end of file diff --git a/data/README.md b/data/README.md new file mode 100644 index 0000000..539798b --- /dev/null +++ b/data/README.md @@ -0,0 +1,4 @@ +# Data Files + +Keep data files for each project here, under separate subdirectories named by project. Try to avoid storing large files (~1GB or more) in Git by adding them to your `.gitignore` file. + @@ -0,0 +1,318 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 + http://maven.apache.org/maven-v4_0_0.xsd"> + + <!--Make sure modelVersion is 4.0.0 --> + <modelVersion>4.0.0</modelVersion> + <!-- groupId is used to identify the organization --> + <groupId>edu.brown.cs</groupId> + <!-- artifactId is used to name the specific project --> + <artifactId>term-project</artifactId> + <!-- type of file you want to output --> + <packaging>jar</packaging> + <!-- Version of your project --> + <version>1.0</version> + + <!-- Defines UTF-8 encoding --> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <!-- Dependencies section for libraries put all of your libraries in here --> + <dependencies> + + <!-- + jopt-simple is a command line parser. + https://pholser.github.io/jopt-simple/. + --> + <dependency> + <groupId>net.sf.jopt-simple</groupId> + <artifactId>jopt-simple</artifactId> + <version>6.0-alpha-3</version> + </dependency> + + <!-- + junit is a testing framework. + http://junit.org/junit4/. + --> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.13</version> + </dependency> + + <!-- + Hamcrest is used for creating assertion tests in junit. + https://github.com/hamcrest/JavaHamcrest. + --> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-all</artifactId> + <version>1.3</version> + </dependency> + + <!-- + Simple Logging Facade for Java is a logging tool for debugging. + https://www.slf4j.org/. + --> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>2.0.0-alpha1</version> + </dependency> + + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-jdk14</artifactId> + <version>2.0.0-alpha1</version> + </dependency> + + <!-- + Google Guava is a useful collections library. + https://github.com/google/guava. + --> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <version>28.2-jre</version> + </dependency> + + <!-- + Google GSON is a library for serialization/deserialization of JSON. + https://github.com/google/gson. + --> + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <version>2.8.6</version> + </dependency> + + <!-- + Spark is a web framework for java. + http://sparkjava.com/. + --> + <dependency> + <groupId>com.sparkjava</groupId> + <artifactId>spark-core</artifactId> + <version>2.9.1</version> + </dependency> + + <!-- + Dependency for freemarker templating language. + http://freemarker.org/. + --> + <dependency> + <groupId>com.sparkjava</groupId> + <artifactId>spark-template-freemarker</artifactId> + <version>2.7.1</version> + </dependency> + + <!-- + SQLite dependency for databases. + https://bitbucket.org/xerial/sqlite-jdbc. + --> + <dependency> + <groupId>org.xerial</groupId> + <artifactId>sqlite-jdbc</artifactId> + <version>3.30.1</version> + </dependency> + </dependencies> + + <!-- Build section --> + <build> + <plugins> + + <!-- Maven compiler plugin for compiling Java 11 --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.8.1</version> + <configuration> + <source>11</source> + <target>11</target> + <compilerArgument>-Xlint:all</compilerArgument> + <showWarnings>true</showWarnings> + <showDeprecation>true</showDeprecation> + </configuration> + </plugin> + <plugin> + <groupId>org.jacoco</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + <version>0.8.5</version> + <executions> + <execution> + <id>default-prepare-agent</id> + <goals> + <goal>prepare-agent</goal> + </goals> + </execution> + <execution> + <id>default-report</id> + <goals> + <goal>report</goal> + </goals> + </execution> + <execution> + <id>default-check</id> + <goals> + <goal>check</goal> + </goals> + <configuration> + <rules> + <rule> + <element>BUNDLE</element> + <limits> + <limit> + <counter>COMPLEXITY</counter> + <value>COVEREDRATIO</value> + <minimum>0.50</minimum> + </limit> + </limits> + </rule> + </rules> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>3.0.0-M4</version> + </plugin> + <!-- Minimum maven version is 3.6.0 --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-enforcer-plugin</artifactId> + <version>3.0.0-M3</version> + <executions> + <execution> + <id>enforce-maven</id> + <goals> + <goal>enforce</goal> + </goals> + <configuration> + <rules> + <requireMavenVersion> + <version>3.6.0</version> + </requireMavenVersion> + </rules> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <!-- Reporting Section --> + <reporting> + <plugins> + + <!-- + Plugin used to report on project dependencies. + https://maven.apache.org/plugins/maven-project-info-reports-plugin/. + --> + <plugin> + <artifactId>maven-project-info-reports-plugin</artifactId> + <version>2.7</version> + <configuration> + <!-- Until it uses BCEL 6.0, details breaks on Java 11 --> + <dependencyDetailsEnabled>false</dependencyDetailsEnabled> + <!-- jetty related locations can't be found, just skip. --> + <dependencyLocationsEnabled>false</dependencyLocationsEnabled> + </configuration> + </plugin> + + <!-- + Maven JXR plugin used with PMD plugin for referencing code errors. + https://maven.apache.org/jxr/maven-jxr-plugin/. + --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jxr-plugin</artifactId> + <version>3.0.0</version> + </plugin> + + <!-- + Javadoc plugin for generating javadoc site. + https://maven.apache.org/plugins/maven-javadoc-plugin/. + --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>3.1.1</version> + <reportSets> + <reportSet> + <reports> + <report>javadoc</report> + </reports> + </reportSet> + </reportSets> + <configuration> + <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable> + </configuration> + </plugin> + + <!-- Uses cs32_checks.xml in config directory to check project style --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <version>3.1.0</version> + <configuration> + <configLocation>config/cs32_checks.xml</configLocation> + </configuration> + </plugin> + + <!-- + PMD looks for bad coding practices such as unused variables. + https://maven.apache.org/plugins/maven-pmd-plugin/. + --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-pmd-plugin</artifactId> + <version>3.12.0</version> + </plugin> + + <!-- + spotbugs plugin to highlight possible code errors. + https://spotbugs.readthedocs.io/en/latest/maven.html. + --> + <plugin> + <groupId>com.github.spotbugs</groupId> + <artifactId>spotbugs-maven-plugin</artifactId> + <version>3.1.12.2</version> + <configuration> + <!-- + Enable analysis which takes more memory but finds more bugs. + If you run out of memory, change the value to 'Low'. + --> + <effort>Max</effort> + <!-- Report all bugs (other values are medium and max) --> + <threshold>Low</threshold> + </configuration> + </plugin> + + <!-- + jacoco creates a "coverage" report, so you can see what + lines of codes and bracnhes your tests exercise. + --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-report-plugin</artifactId> + <version>3.0.0-M4</version> + </plugin> + <plugin> + <groupId>org.jacoco</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + <reportSets> + <reportSet> + <reports> + <!-- select non-aggregate reports --> + <report>report</report> + </reports> + </reportSet> + </reportSets> + </plugin> + + </plugins> + </reporting> +</project>
\ No newline at end of file @@ -0,0 +1,49 @@ +#!/bin/sh + +# To run our code, we must have it in our classpath. +# We use $(ls target/*.jar) instead of target/stars-1.0.jar so that +# this script can be reused in other projects more easily. + +TARGET=$(ls target/*.jar 2>/dev/null) +if [ -z "$TARGET" ]; then + echo "No jar file in target/, try 'mvn package'". + exit 1 +fi + +# In the pom.xml, we've already explained other what libraries we +# depend on. Maven downloaded them, and put them "somewhere" (our +# repository). Now we ask maven to build up the CLASSPATH that let us +# run against those libraries. + +# First, we put the CLASSPATH in .classpath if the pom.xml is newer +# than out existing .classpath file. (We avoid this command if +# .classpath is fresh, since it's rather slow.) +if [ ! .mvn-classpath -nt pom.xml ]; then + mvn dependency:build-classpath -Dmdep.outputFile=.mvn-classpath -q +fi + +# Now, we set $CP to the contents of the .classpath file. +CP=$(cat .mvn-classpath) + +# We're trying to make the script more reusable by finding the package +# name, instead of hard coding. But this relies on some conventions +# in naming. You'll have to call your class "Main" and use our +# recommended package structure. + +# Find Main.java. It should be in a package below your username package. +MAIN=$(ls src/main/java/edu/brown/cs/*/*/Main.java) +[ -z "$MAIN" ] && echo "You need a Main.java" && exit 1 +[ ! -e "$MAIN" ] && echo "You can only have one Main.java" && exit 1 +STUDENT=$(basename $(dirname $(dirname $MAIN))) +MAINPKG=$(basename $(dirname $MAIN)) + +# No guarantees yet, but we're trying to support Windows, which uses a +# different Path Separator in classpaths. +PATHSEP=":" +if [ "$OSTYPE" = 'cygwin' -o "$OSTYPE" = 'msys' ]; then + PATHSEP=";" +fi + +# The symbol "$@" passes the command-line arguments from +# this script to your Java program. +java -ea -cp "$TARGET$PATHSEP$CP" edu.brown.cs.$STUDENT.$MAINPKG.Main "$@" diff --git a/src/main/java/edu/brown/cs/student/stars/Main.java b/src/main/java/edu/brown/cs/student/stars/Main.java new file mode 100644 index 0000000..61127b5 --- /dev/null +++ b/src/main/java/edu/brown/cs/student/stars/Main.java @@ -0,0 +1,62 @@ +package edu.brown.cs.student.stars; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Map; + +import joptsimple.OptionParser; +import joptsimple.OptionSet; +import spark.ExceptionHandler; +import spark.ModelAndView; +import spark.Request; +import spark.Response; +import spark.Spark; +import spark.TemplateViewRoute; +import spark.template.freemarker.FreeMarkerEngine; + +import com.google.common.collect.ImmutableMap; + +import freemarker.template.Configuration; + +/** + * The Main class of our project. This is where execution begins. + * + */ +public final class Main { + + private static final int DEFAULT_PORT = 4567; + + /** + * The initial method called when execution begins. + * + * @param args + * An array of command line arguments + */ + public static void main(String[] args) { + new Main(args).run(); + } + + private String[] args; + + private Main(String[] args) { + this.args = args; + } + + private void run() { + // Parse command line arguments + OptionParser parser = new OptionParser(); + parser.accepts("gui"); + parser.accepts("port").withRequiredArg().ofType(Integer.class) + .defaultsTo(DEFAULT_PORT); + OptionSet options = parser.parse(args); + + if (options.has("gui")) { + //do a gui type thing + //runSparkServer((int) options.valueOf("port")); + } + + // TODO: Process commands in a REPL + } +}
\ No newline at end of file diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..97d2f16 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,4 @@ +# System Tests + +All system tests should be stored in this directory. Please keep the tests you write separate from TA provided tests. + |