Skip to content

Commit

Permalink
clang-format: format entire codebase
Browse files Browse the repository at this point in the history
* clang-format: simplify to BasedOnStyle and overrides

* clang-format: format everything

* clang-format: sort includes

* clang-format: reduce ColumnLimit to 90

* clang-format: set BreakConstructorInitializers: BeforeComma

* clang-tidy: init, start with readability-braces-around-statements

* clang-tidy: add modernize-deprecated-headers

* clang-tidy: add modernize-use-using
  • Loading branch information
mapd-bot authored and andrewseidl committed Jul 21, 2018
1 parent 9bd6f84 commit fe04041
Show file tree
Hide file tree
Showing 351 changed files with 31,901 additions and 18,418 deletions.
60 changes: 2 additions & 58 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,62 +1,6 @@
BasedOnStyle: Chromium
---
Language: Cpp
AccessModifierOffset: -1
ConstructorInitializerIndentWidth: 4
AlignEscapedNewlinesLeft: true
AlignAfterOpenBracket: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AlwaysBreakAfterDefinitionReturnType: false
AlwaysBreakTemplateDeclarations: true
AlwaysBreakBeforeMultilineStrings: true
BreakBeforeBinaryOperators: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BinPackArguments: false
BinPackParameters: false
ColumnLimit: 120
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
DerivePointerAlignment: false
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: true
IndentWrappedFunctionNames: false
IndentFunctionDeclarationAfterType: false
MaxEmptyLinesToKeep: 1
KeepEmptyLinesAtTheStartOfBlocks: false
NamespaceIndentation: None
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakString: 1000
PenaltyBreakFirstLessLess: 120
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
SpacesBeforeTrailingComments: 2
Cpp11BracedListStyle: true
Standard: Cpp11
ColumnLimit: 90
IndentWidth: 2
TabWidth: 8
UseTab: Never
BreakBeforeBraces: Attach
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpacesInAngles: false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpaceAfterCStyleCast: false
SpacesInContainerLiterals: true
SpaceBeforeAssignmentOperators: true
ContinuationIndentWidth: 4
CommentPragmas: '^ IWYU pragma:'
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
SpaceBeforeParens: ControlStatements
DisableFormat: false
...

BreakConstructorInitializers: BeforeComma
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Checks: -*,readability-braces-around-statements,modernize-deprecated-headers,modernize-use-using
885 changes: 579 additions & 306 deletions Analyzer/Analyzer.cpp

Large diffs are not rendered by default.

535 changes: 338 additions & 197 deletions Analyzer/Analyzer.h

Large diffs are not rendered by default.

22 changes: 15 additions & 7 deletions Archive/Archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#ifndef ARCHIVE_ARCHIVE_H_
#define ARCHIVE_ARCHIVE_H_

#include <string>
#include <regex>
#include <string>

#include <archive.h>
#include <archive_entry.h>
Expand All @@ -28,13 +28,15 @@
// etc are derived.
class Archive {
public:
Archive(const std::string url, const bool plain_text) : url(url), plain_text(plain_text) {
Archive(const std::string url, const bool plain_text)
: url(url), plain_text(plain_text) {
parse_url(url, url_parts);

if (0 == (ar = archive_read_new()))
throw std::runtime_error(std::string("archive_read_new failed!"));

//!! LIBARCHIVE_ENABLE_ALL may trigger exception "detect_column_types error: libarchive error: Missing type keyword in
//!! LIBARCHIVE_ENABLE_ALL may trigger exception "detect_column_types error: libarchive
//! error: Missing type keyword in
//! mtree specification"
//!! on ridiculously simple raw data
//#define LIBARCHIVE_ENABLE_ALL
Expand Down Expand Up @@ -84,7 +86,8 @@ class Archive {

virtual std::string archive_error(int err) {
auto cstr = archive_error_string(ar);
return std::string("libarchive error: ") + (cstr ? std::string(cstr) : std::to_string(err));
return std::string("libarchive error: ") +
(cstr ? std::string(cstr) : std::to_string(err));
}

virtual bool read_next_header() {
Expand Down Expand Up @@ -135,9 +138,13 @@ class Archive {
return ((Archive*)client_data)->read(buff);
}

static int open(struct archive* a, void* client_data) { return ((Archive*)client_data)->open(); }
static int open(struct archive* a, void* client_data) {
return ((Archive*)client_data)->open();
}

static int close(struct archive* a, void* client_data) { return ((Archive*)client_data)->close(); }
static int close(struct archive* a, void* client_data) {
return ((Archive*)client_data)->close();
}

static void parse_url(const std::string url, std::map<int, std::string>& url_parts) {
/*
Expand All @@ -155,7 +162,8 @@ class Archive {
9: cool
*/
std::smatch sm;
std::regex url_regex(R"(^(([^:\/?#]+):)?(//([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?)", std::regex::extended);
std::regex url_regex(R"(^(([^:\/?#]+):)?(//([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?)",
std::regex::extended);
if (!std::regex_match(url, sm, url_regex))
throw std::runtime_error(std::string("malformed url: ") + url);

Expand Down
16 changes: 10 additions & 6 deletions Archive/PosixFileArchive.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ class PosixFileArchive : public Archive {
const size_t buf_size = (1 << 20);

public:
PosixFileArchive(const std::string url, const bool plain_text) : Archive(url, plain_text) {
PosixFileArchive(const std::string url, const bool plain_text)
: Archive(url, plain_text) {
// some well-known file.exts imply plain text
if (!this->plain_text)
this->plain_text =
boost::filesystem::extension(url_part(5)) == ".csv" || boost::filesystem::extension(url_part(5)) == ".tsv" ||
boost::filesystem::extension(url_part(5)) == ".txt" || boost::filesystem::extension(url_part(5)) == "";
this->plain_text = boost::filesystem::extension(url_part(5)) == ".csv" ||
boost::filesystem::extension(url_part(5)) == ".tsv" ||
boost::filesystem::extension(url_part(5)) == ".txt" ||
boost::filesystem::extension(url_part(5)) == "";

if (this->plain_text)
buf = new char[buf_size];
Expand All @@ -51,10 +53,12 @@ class PosixFileArchive : public Archive {
auto file_path = url_part(5);
if (plain_text) {
if (nullptr == (fp = fopen(file_path.c_str(), "r")))
throw std::runtime_error(std::string("fopen(") + file_path + "): " + strerror(errno));
throw std::runtime_error(std::string("fopen(") + file_path +
"): " + strerror(errno));
} else {
if (ARCHIVE_OK != archive_read_open_filename(ar, file_path.c_str(), 1 << 16))
throw std::runtime_error(std::string("fopen(") + file_path + "): " + strerror(errno));
throw std::runtime_error(std::string("fopen(") + file_path +
"): " + strerror(errno));
}
}

Expand Down
Loading

0 comments on commit fe04041

Please sign in to comment.