Week 10 Class 18 Thu Mar 16 Posted: Mar 16
Announcements
int
to std::string
, use std::to_string()
.Class
All exercises are due by 4:30 pm on Monday, Mar 27
The article How to Write a Git Commit Message has guidance on commit messages in general and Git projects specifically. Especially note the 7 rules. As the writeup mentions, these ideas are not new.
A message with only a subject line is adequate for our projects. The rules that only concern the subject are:
Make sure to use these guidelines as you implement any projects or exercises.
In Project 3: TDD, you will follow a TDD process to implement code submitted via a GitHub Classroom repository. An invitation link to create the repository is on the Brightspace course page.
Due Dates:
The input for a (source) code-analysis project is source code that can come from multiple sources, including solitary files (e.g., main.cpp), directories of source-code files (e.g., src/), source-code archives (e.g., project.tar.gz, file.zip), and standard input (i.e., stdin, e.g., std::cin).
In addition, solitary files and source-code archives can include a URL, e.g., https://raw.githubusercontent.com/UAComputerScience/sorttdd-mlcollard/main/sortTest.cpp
To perform the code analysis, the source code is wrapped in a single XML element with metadata about the source code, including filename, programming language, url, hash, and LOC (lines of code). For the source-code example, the resulting XML has the following attributes:
Attribute | XML Example |
---|---|
language | language="C++" |
url | url="http://mlcollard.net/fragment.cpp" |
filename | filename="fragment.cpp" |
LOC | loc="3" |
hash | hash="39dcad4f59855aa76420aa3d69af3d7ba30a91bb" |
The hash is of the source and is a SHA1 160-bit (20 bytes) represented in 40 hex characters, which Git uses. Note that the xmlns:code="http://mlcollard.net/code"
is not an attribute, but an XML namespace declaration, handled automatically by XMLWrapper.
The programming language is typically determined from the file extension, e.g., .cpp for C++, but exceptions exist. The variety of input sources and program options for the metadata follows the rules stated below.
Implement the below rules following a Test-Driven Development (TDD) approach. Write a test in CodeAnalysisTest.cpp, and implement the minimal code necessary to get it working in CodeAnalysis.cpp, refactor/clean up the code to make it clear and logical, then commit with an appropriate commit message. You are encouraged to commit more than once per test case, e.g., after entering the minimal code to solve the problem and refactor/clean up the code.
std::cin
) of a regular file, the disk filename is a single dash "-" and the entry filename is the literal string "data". In this case, you must use the option filename for the attribute filename.std::cin
) of a source-code archive, the disk filename is a single dash "-". In this case, use the entry filename for the attribute filename.All error messages are written to standard error (i.e., std::cerr), and the function should return an empty string.
Your score will depend on the following: