Browse code

pass lintr

Tom Sherman authored on 20/06/2018 18:41:47
Showing13 changed files

... ...
@@ -4266,41 +4266,6 @@ else
4266 4266
   :
4267 4267
 fi
4268 4268
 
4269
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C++ compiler accepts -Wno-unused-function" >&5
4270
-$as_echo_n "checking whether C++ compiler accepts -Wno-unused-function... " >&6; }
4271
-if ${ax_cv_check_cxxflags___Wno_unused_function+:} false; then :
4272
-  $as_echo_n "(cached) " >&6
4273
-else
4274
-
4275
-  ax_check_save_flags=$CXXFLAGS
4276
-  CXXFLAGS="$CXXFLAGS  -Wno-unused-function"
4277
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4278
-/* end confdefs.h.  */
4279
-
4280
-int
4281
-main ()
4282
-{
4283
-
4284
-  ;
4285
-  return 0;
4286
-}
4287
-_ACEOF
4288
-if ac_fn_cxx_try_compile "$LINENO"; then :
4289
-  ax_cv_check_cxxflags___Wno_unused_function=yes
4290
-else
4291
-  ax_cv_check_cxxflags___Wno_unused_function=no
4292
-fi
4293
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4294
-  CXXFLAGS=$ax_check_save_flags
4295
-fi
4296
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cxxflags___Wno_unused_function" >&5
4297
-$as_echo "$ax_cv_check_cxxflags___Wno_unused_function" >&6; }
4298
-if test "x$ax_cv_check_cxxflags___Wno_unused_function" = xyes; then :
4299
-  GAPS_CXX_FLAGS+=" -Wno-unused-function "
4300
-else
4301
-  :
4302
-fi
4303
-
4304 4269
 fi
4305 4270
 
4306 4271
 # set compile flags for SIMD
... ...
@@ -49,8 +49,8 @@ if test "x$warnings" = "xyes" ; then
49 49
     AX_CHECK_COMPILE_FLAG([-Wall], [GAPS_CXX_FLAGS+=" -Wall "])
50 50
     AX_CHECK_COMPILE_FLAG([-Wextra], [GAPS_CXX_FLAGS+=" -Wextra "])
51 51
     AX_CHECK_COMPILE_FLAG([-Werror], [GAPS_CXX_FLAGS+=" -Werror "])
52
-    AX_CHECK_COMPILE_FLAG([-Wno-unused-parameter], [GAPS_CXX_FLAGS+=" -Wno-unused-parameter "])
53
-    AX_CHECK_COMPILE_FLAG([-Wno-unused-function], [GAPS_CXX_FLAGS+=" -Wno-unused-function "])
52
+    AX_CHECK_COMPILE_FLAG([-Wno-unused-parameter],
53
+        [GAPS_CXX_FLAGS+=" -Wno-unused-parameter "])
54 54
 fi
55 55
 
56 56
 # set compile flags for SIMD
... ...
@@ -6,9 +6,9 @@
6 6
 static RowMatrix convertRMatrix(const Rcpp::NumericMatrix &rmat)
7 7
 {
8 8
     RowMatrix mat(rmat.nrow(), rmat.ncol());
9
-    for (unsigned i = 0; i < rmat.nrow(); ++i)
9
+    for (unsigned i = 0; i < mat.nRow(); ++i)
10 10
     {
11
-        for (unsigned j = 0; j < rmat.ncol(); ++j)
11
+        for (unsigned j = 0; j < mat.nCol(); ++j)
12 12
         {
13 13
             mat(i,j) = rmat(i,j);
14 14
         }
... ...
@@ -13,20 +13,20 @@
13 13
 #endif
14 14
 
15 15
 #ifdef GAPS_DEBUG
16
-    #define GAPS_ASSERT(cond)                                           \
17
-        do {                                                            \
18
-            if (!(cond))                                                \
19
-            {                                                           \
20
-                gaps_printf("assert failed %s %d\n", __FILE__, __LINE__);   \
21
-                std::exit(0);                                           \
22
-            }                                                           \
16
+    #define GAPS_ASSERT(cond)                                             \
17
+        do {                                                              \
18
+            if (!(cond))                                                  \
19
+            {                                                             \
20
+                gaps_printf("assert failed %s %d\n", __FILE__, __LINE__); \
21
+                std::exit(0);                                             \
22
+            }                                                             \
23 23
         } while(0)
24 24
 
25 25
     #define GAPS_ASSERT_MSG(cond, msg)                                  \
26 26
         do {                                                            \
27 27
             if (!(cond))                                                \
28 28
             {                                                           \
29
-                gaps_cout << "assert failed " << __FILE__ << " " <<   \
29
+                gaps_cout << "assert failed " << __FILE__ << " " <<     \
30 30
                     __LINE__ << " , " << msg << '\n';                   \
31 31
                 std::exit(0);                                           \
32 32
             }                                                           \
... ...
@@ -42,10 +42,7 @@
42 42
 #define gaps_stop std::exit(0)
43 43
 #endif
44 44
 
45
-#define GAPS_ERROR(msg)                             \
46
-    do {                                            \
47
-        gaps_cout << "error: " << msg << '\n';    \
48
-        gaps_stop;                              \
49
-    } while(0)
45
+// NOLINTNEXTLINE
46
+#define GAPS_ERROR(msg) do {gaps_cout << "error: " << msg << '\n'; gaps_stop;} while(0)
50 47
 
51 48
 #endif
52 49
\ No newline at end of file
... ...
@@ -6,6 +6,7 @@
6 6
     #include <omp.h>
7 7
 #endif
8 8
 
9
+/*
9 10
 static std::vector< std::vector<unsigned> > sampleIndices(unsigned n, unsigned nSets)
10 11
 {
11 12
     unsigned setSize = n / nSets;
... ...
@@ -26,6 +27,7 @@ static std::vector< std::vector<unsigned> > sampleIndices(unsigned n, unsigned n
26 27
     sampleIndices.push_back(toBeSampled);
27 28
     return sampleIndices;
28 29
 }
30
+*/
29 31
 
30 32
 void GapsDispatcher::runOneCycle(unsigned k)
31 33
 {
... ...
@@ -52,13 +52,16 @@ private:
52 52
 
53 53
     void runOneCycle(unsigned k);
54 54
 
55
+    GapsDispatcher(const GapsDispatcher &p); // don't allow copies
56
+    GapsDispatcher& operator=(const GapsDispatcher &p); // don't allow copies
57
+
55 58
 public:
56 59
 
57
-    GapsDispatcher(uint32_t seed=0) : mNumPatterns(3), mMaxIterations(1000),
58
-        mOutputFrequency(250), mSeed(seed), mAlphaA(0.01), mAlphaP(0.01),
59
-        mMaxGibbsMassA(100.f), mMaxGibbsMassP(100.f), mPrintMessages(true),
60
-        mSingleCell(false), mDataIsLoaded(false), mNumCoresPerSet(1),
61
-        mFixedMatrix('N')
60
+    explicit GapsDispatcher(uint32_t seed=0) : mNumPatterns(3),
61
+        mMaxIterations(1000), mOutputFrequency(250), mSeed(seed), mAlphaA(0.01),
62
+        mAlphaP(0.01), mMaxGibbsMassA(100.f), mMaxGibbsMassP(100.f),
63
+        mPrintMessages(true), mSingleCell(false), mDataIsLoaded(false),
64
+        mNumCoresPerSet(1), mFixedMatrix('N')
62 65
     {
63 66
         gaps::random::setSeed(mSeed);
64 67
     }
... ...
@@ -22,9 +22,9 @@ private:
22 22
 public:
23 23
 
24 24
     RowMatrix(unsigned nrow, unsigned ncol);
25
+    explicit RowMatrix(const ColMatrix &mat);
25 26
 
26
-    RowMatrix(const std::string &p);
27
-    RowMatrix(const ColMatrix &mat);
27
+    explicit RowMatrix(const std::string &path);
28 28
     //RowMatrix(const std::string &p, bool parseRows, std::vector<unsigned> whichIndices);
29 29
 
30 30
     unsigned nRow() const {return mNumRows;}
... ...
@@ -58,9 +58,9 @@ private:
58 58
 public:
59 59
 
60 60
     ColMatrix(unsigned nrow, unsigned ncol);
61
-    ColMatrix(const RowMatrix &mat);
61
+    explicit ColMatrix(const RowMatrix &mat);
62 62
 
63
-    ColMatrix(const std::string &p);
63
+    explicit ColMatrix(const std::string &path);
64 64
     //ColMatrix(const std::string &p, bool parseRows, std::vector<unsigned> whichIndices);
65 65
 
66 66
     unsigned nRow() const {return mNumRows;}
... ...
@@ -19,6 +19,9 @@ private:
19 19
     unsigned mCurrentRow;
20 20
     unsigned mCurrentCol;
21 21
 
22
+    CsvParser(const CsvParser &p); // don't allow copies
23
+    CsvParser& operator=(const CsvParser &p); // don't allow copies
24
+
22 25
 public:
23 26
 
24 27
     explicit CsvParser(const std::string &path);
... ...
@@ -1,7 +1,7 @@
1 1
 #include "../GapsAssert.h"
2
+#include "CsvParser.h"
2 3
 #include "FileParser.h"
3 4
 #include "MtxParser.h"
4
-#include "CsvParser.h"
5 5
 #include "TsvParser.h"
6 6
 
7 7
 #include <string>
... ...
@@ -16,14 +16,15 @@ enum GapsFileType
16 16
 
17 17
 static GapsFileType fileType(const std::string &path)
18 18
 {
19
-    std::size_t pos = path.find_last_of(".");
19
+    std::size_t pos = path.find_last_of('.');
20 20
     std::string ext = path.substr(pos);
21 21
 
22
-    if (ext.find("/") != std::string::npos) { return GAPS_INVALID_FILE_TYPE; }
23
-    else if (ext == ".mtx") { return GAPS_MTX; }
24
-    else if (ext == ".csv") { return GAPS_CSV; }
25
-    else if (ext == ".tsv") { return GAPS_TSV; }
26
-    else { return GAPS_INVALID_FILE_TYPE; }
22
+    if (ext.find('/') != std::string::npos) { return GAPS_INVALID_FILE_TYPE; }
23
+    if (ext == ".mtx") { return GAPS_MTX; }
24
+    if (ext == ".csv") { return GAPS_CSV; }
25
+    if (ext == ".tsv") { return GAPS_TSV; }
26
+
27
+    return GAPS_INVALID_FILE_TYPE;
27 28
 }
28 29
 
29 30
 AbstractFileParser* AbstractFileParser::create(const std::string &path)
... ...
@@ -6,8 +6,15 @@
6 6
 // file parser interface
7 7
 class AbstractFileParser
8 8
 {
9
+private:
10
+
11
+    AbstractFileParser(const AbstractFileParser &p); // don't allow copies
12
+    AbstractFileParser& operator=(const AbstractFileParser &p); // don't allow copies
13
+
9 14
 public:
10 15
 
16
+    AbstractFileParser() {}
17
+
11 18
     static AbstractFileParser* create(const std::string &path);
12 19
 
13 20
     virtual ~AbstractFileParser() = 0;
... ...
@@ -16,6 +16,9 @@ private:
16 16
     unsigned mNumRows;
17 17
     unsigned mNumCols;
18 18
 
19
+    MtxParser(const MtxParser &p); // don't allow copies
20
+    MtxParser& operator=(const MtxParser &p); // don't allow copies
21
+
19 22
 public:
20 23
 
21 24
     explicit MtxParser(const std::string &path);
... ...
@@ -19,6 +19,9 @@ private:
19 19
     unsigned mCurrentRow;
20 20
     unsigned mCurrentCol;
21 21
 
22
+    TsvParser(const TsvParser &p); // don't allow copies
23
+    TsvParser& operator=(const TsvParser &p); // don't allow copies
24
+
22 25
 public:
23 26
 
24 27
     explicit TsvParser(const std::string &path);
25 28
new file mode 100644
26 29
Binary files /dev/null and b/tests/testthat/test_ar.temp differ