Skip to content

Commit

Permalink
Merge pull request #1012 from slaclab/ESROGUE-554
Browse files Browse the repository at this point in the history
Adding C++ linter to CI
  • Loading branch information
ruck314 authored Jul 10, 2024
2 parents 49886b5 + bbee743 commit c2ddf8e
Show file tree
Hide file tree
Showing 270 changed files with 1,397 additions and 1,549 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/rogue_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,26 @@ jobs:
cache: 'pip'
cache-dependency-path: 'pip_requirements.txt'

# Install dependencies
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install doxygen doxygen-doc libzmq3-dev libboost-all-dev
pip install -r pip_requirements.txt
# Flake 8 check
- name: Flake8 Tests
# Python Linter
- name: Python Linter
run: |
python -m compileall -f ./python/
flake8 --count ./python/
python -m compileall -f ./tests
flake8 --count ./tests/
# C++ Linter
- name: C++ Linter
run: |
find . -name '*.h' -o -name '*.cpp' | xargs cpplint
# Rogue
- name: Build Rogue
run: |
Expand Down
Empty file added =
Empty file.
34 changes: 34 additions & 0 deletions CPPLINT.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#######################################################
# CPPLINT.cfg
#######################################################

# Increase the max number of characters on a given line
linelength=250

# List of filters to apply
filter=-legal/copyright

# Suppress the warning for unapproved C++11 headers
# Required for "<thread> is an unapproved C++11 header"
filter=-build/c++11

# Disable the build/include_order check
# Required for #include "rogue/Directives.h" to be at start
filter=-build/include_order

# Disable the build/header_guard check
# Note changing header guard has wrong style
# E.g. from __ROGUE_UTILITIES_FILEIO_MODULE_H__ to INCLUDE_ROGUE_UTILITIES_MODULE_H_
filter=-build/header_guard

# Disable whitespace/indent check
# private/public: indent will be based on .clang-format format"
filter=-whitespace/indent

# Disable runtime/arrays
# TODO: We should fix in the future
filter=-runtime/arrays

# Disable runtime/references
# TODO: We should fix in the future
filter=-runtime/references
5 changes: 1 addition & 4 deletions include/rogue/Directives.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/**
*-----------------------------------------------------------------------------
* Title : Common Directives
* ----------------------------------------------------------------------------
* File : Directives.h
* Created : 2023-02-13
* Company : SLAC National Accelerator Laboratory
* ----------------------------------------------------------------------------
* Description:
* Common Directives For Rogue
Expand Down
5 changes: 1 addition & 4 deletions include/rogue/EnableSharedFromThis.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/**
*-----------------------------------------------------------------------------
* Title : Common virtual class to enable shared_from_this() calls.
* ----------------------------------------------------------------------------
* File : EnableSharedFromThis.h
* Created : 2019-11-15
* Company : SLAC National Accelerator Laboratory
* ----------------------------------------------------------------------------
* Description:
* This is a common parent class that must be used instead of std::enable_shared_from_this
Expand Down
5 changes: 1 addition & 4 deletions include/rogue/GeneralError.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/**
*-----------------------------------------------------------------------------
* Title : General Error
* ----------------------------------------------------------------------------
* File : GeneralError.h
* Created : 2017-12-05
* Company : SLAC National Accelerator Laboratory
* ----------------------------------------------------------------------------
* Description:
* General exception for Rogue
Expand Down
5 changes: 1 addition & 4 deletions include/rogue/GilRelease.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/**
*-----------------------------------------------------------------------------
* Title : Release GIL within scope.
* ----------------------------------------------------------------------------
* File : GilRelease.h
* Created : 2017-02-28
* Company : SLAC National Accelerator Laboratory
* ----------------------------------------------------------------------------
* Description:
* Release GIL for the scope of this class.
Expand Down
5 changes: 1 addition & 4 deletions include/rogue/Helpers.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/**
*-----------------------------------------------------------------------------
* Title : Helpful Functions
* ----------------------------------------------------------------------------
* File : Helpers.h
* Created : 2018-11-28
* Company : SLAC National Accelerator Laboratory
* ----------------------------------------------------------------------------
* Description:
* Helper functions for Rogue
Expand Down
7 changes: 2 additions & 5 deletions include/rogue/Logging.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/**
*-----------------------------------------------------------------------------
* Title : Logging interface
* ----------------------------------------------------------------------------
* File : Logging.h
* Created : 2017-02-28
* Company : SLAC National Accelerator Laboratory
* ----------------------------------------------------------------------------
* Description:
* Logging interface for pyrogue
Expand Down Expand Up @@ -73,7 +70,7 @@ class Logging {

static std::shared_ptr<rogue::Logging> create(std::string name, bool quiet = false);

Logging(std::string name, bool quiet = false);
explicit Logging(std::string name, bool quiet = false);
~Logging();

static void setLevel(uint32_t level);
Expand Down
5 changes: 1 addition & 4 deletions include/rogue/Queue.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/**
*-----------------------------------------------------------------------------
* Title : General Queue
* ----------------------------------------------------------------------------
* File : Queue.h
* Created : 2017-01-18
* Company : SLAC National Accelerator Laboratory
* ----------------------------------------------------------------------------
* Description:
* General queue for Rogue
Expand Down
5 changes: 1 addition & 4 deletions include/rogue/ScopedGil.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/**
*-----------------------------------------------------------------------------
* Title : Scoped GIL
* ----------------------------------------------------------------------------
* File : ScopedGil.h
* Created : 2017-02-28
* Company : SLAC National Accelerator Laboratory
* ----------------------------------------------------------------------------
* Description:
* Acquire the GIL for the scope of this class.
Expand Down
5 changes: 1 addition & 4 deletions include/rogue/Version.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/**
*-----------------------------------------------------------------------------
* Title : Rogue Version
* ----------------------------------------------------------------------------
* File : Version.h
* Created : 2017-05-17
* Company : SLAC National Accelerator Laboratory
* ----------------------------------------------------------------------------
* Description:
* Version helpers for Rogue
Expand Down
8 changes: 4 additions & 4 deletions include/rogue/hardware/MemMap.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
*-----------------------------------------------------------------------------
* Title : Raw Memory Mapped Access
* ----------------------------------------------------------------------------
* File : MemMap.h
* Created : 2019-11-18
* Company : SLAC National Accelerator Laboratory
* ----------------------------------------------------------------------------
* Description:
* Raw Memory Mapped Access
* ----------------------------------------------------------------------------
* This file is part of the rogue software platform. It is subject to
* the license terms in the LICENSE.txt file found in the top-level directory
Expand Down
11 changes: 6 additions & 5 deletions include/rogue/hardware/axi/AxiMemMap.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
*-----------------------------------------------------------------------------
* Title : AXI Memory Mapped Access
* ----------------------------------------------------------------------------
* File : AxiMemMap.h
* Created : 2017-03-21
* Company : SLAC National Accelerator Laboratory
* ----------------------------------------------------------------------------
* Description:
* AXI Memory Mapped Access
* ----------------------------------------------------------------------------
* This file is part of the rogue software platform. It is subject to
* the license terms in the LICENSE.txt file found in the top-level directory
Expand All @@ -22,6 +22,7 @@

#include <memory>
#include <mutex>
#include <string>
#include <thread>

#include "rogue/Logging.h"
Expand Down Expand Up @@ -69,7 +70,7 @@ class AxiMemMap : public rogue::interfaces::memory::Slave {
static void setup_python();

// Class Creator
AxiMemMap(std::string path);
explicit AxiMemMap(std::string path);

// Destructor
~AxiMemMap();
Expand Down
10 changes: 7 additions & 3 deletions include/rogue/hardware/axi/AxiStreamDma.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/**
*-----------------------------------------------------------------------------
* Title : AxiStreamDma Interface Class
* ----------------------------------------------------------------------------
* Company : SLAC National Accelerator Laboratory
* ----------------------------------------------------------------------------
* Description:
* AxiStreamDma Interface Class
* ----------------------------------------------------------------------------
* This file is part of the rogue software platform. It is subject to
* the license terms in the LICENSE.txt file found in the top-level directory
Expand All @@ -19,6 +22,7 @@

#include <map>
#include <memory>
#include <string>
#include <thread>

#include "rogue/Logging.h"
Expand All @@ -32,7 +36,7 @@ namespace axi {
//! Storage class for shared memory buffers
class AxiStreamDmaShared {
public:
AxiStreamDmaShared(std::string path);
explicit AxiStreamDmaShared(std::string path);

//! Shared FD
int32_t fd;
Expand Down
5 changes: 1 addition & 4 deletions include/rogue/hardware/axi/module.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/**
*-----------------------------------------------------------------------------
* Title : Python Module
* ----------------------------------------------------------------------------
* File : module.h
* Created : 2017-03-21
* Company : SLAC National Accelerator Laboratory
* ----------------------------------------------------------------------------
* Description:
* Python module setup
Expand Down
16 changes: 8 additions & 8 deletions include/rogue/hardware/drivers/DmaDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <linux/types.h>
#else
#include <stdint.h>

#include <string>
#endif

Expand Down Expand Up @@ -634,7 +635,6 @@ static inline ssize_t dmaGetBuffCount(int32_t fd) {
return (ioctl(fd, DMA_Get_Buff_Count, 0));
}


/**
* dmaGetGitVersion - Get the DMA Driver's Git Version
* @fd: File descriptor to use.
Expand All @@ -644,12 +644,12 @@ static inline ssize_t dmaGetBuffCount(int32_t fd) {
* Returns: The DMA Driver's Git Version string
*/
static inline std::string dmaGetGitVersion(int32_t fd) {
char gitv[32] = {0}; // Initialize with zeros to ensure null-termination
if (ioctl(fd, DMA_Get_GITV, gitv) < 0) {
return "";
}
gitv[32 - 1] = '\0'; // Ensure null-termination
return std::string(gitv);
char gitv[32] = {0}; // Initialize with zeros to ensure null-termination
if (ioctl(fd, DMA_Get_GITV, gitv) < 0) {
return "";
}
gitv[32 - 1] = '\0'; // Ensure null-termination
return std::string(gitv);
}

/**
Expand All @@ -676,7 +676,7 @@ static inline void** dmaMapDma(int32_t fd, uint32_t* count, uint32_t* size) {
if (count != NULL) *count = bCount;
if (size != NULL) *size = bSize;

if ((ret = (void**)malloc(sizeof(void*) * bCount)) == 0) return (NULL);
if ((ret = reinterpret_cast<void**>(malloc(sizeof(void*) * bCount))) == 0) return (NULL);

// Attempt to map
gCount = 0;
Expand Down
4 changes: 2 additions & 2 deletions include/rogue/hardware/module.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
*-----------------------------------------------------------------------------
* Title : Python Module
* ----------------------------------------------------------------------------
* Company : SLAC National Accelerator Laboratory
* ----------------------------------------------------------------------------
* Description:
* Python module setup
Expand Down
9 changes: 5 additions & 4 deletions include/rogue/interfaces/ZmqClient.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
*-----------------------------------------------------------------------------
* Title : Rogue ZMQ Control Interface
* ----------------------------------------------------------------------------
* File : ZmqClient.h
* Created : 2019-05-02
* Company : SLAC National Accelerator Laboratory
* ----------------------------------------------------------------------------
* Description:
* Rogue ZMQ Control Interface
* ----------------------------------------------------------------------------
* This file is part of the rogue software platform. It is subject to
* the license terms in the LICENSE.txt file found in the top-level directory
Expand All @@ -19,6 +19,7 @@
#include "rogue/Directives.h"

#include <memory>
#include <string>
#include <thread>

#include "rogue/Logging.h"
Expand Down
9 changes: 5 additions & 4 deletions include/rogue/interfaces/ZmqServer.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
*-----------------------------------------------------------------------------
* Title : Rogue ZMQ Control Interface
* ----------------------------------------------------------------------------
* File : ZmqServer.h
* Created : 2019-05-02
* Company : SLAC National Accelerator Laboratory
* ----------------------------------------------------------------------------
* Description:
* Rogue ZMQ Control Interface
* ----------------------------------------------------------------------------
* This file is part of the rogue software platform. It is subject to
* the license terms in the LICENSE.txt file found in the top-level directory
Expand All @@ -19,6 +19,7 @@
#include "rogue/Directives.h"

#include <memory>
#include <string>
#include <thread>

#include "rogue/Logging.h"
Expand Down
13 changes: 8 additions & 5 deletions include/rogue/interfaces/api/Bsp.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
*-----------------------------------------------------------------------------
* Title : C++ API Bsp
* ----------------------------------------------------------------------------
* File : Bsp.h
* Created : 2023-04-17
* Company : SLAC National Accelerator Laboratory
* ----------------------------------------------------------------------------
* Description:
* C++ API BSP (Board Support Package)
* ----------------------------------------------------------------------------
* This file is part of the rogue software platform. It is subject to
* the license terms in the LICENSE.txt file found in the top-level directory
Expand All @@ -16,7 +16,10 @@
**/
#ifndef __ROGUE_INTERFACE_API_BSP_H__
#define __ROGUE_INTERFACE_API_BSP_H__

#include <boost/python.hpp>
#include <memory>
#include <string>
#include <vector>

namespace rogue {
Expand All @@ -36,7 +39,7 @@ class Bsp {
static std::shared_ptr<rogue::interfaces::api::Bsp> create(std::string modName, std::string rootClass);

//! Create the object
Bsp(boost::python::object obj);
explicit Bsp(boost::python::object obj);
Bsp(std::string modName, std::string rootClass);
~Bsp();

Expand Down
Loading

0 comments on commit c2ddf8e

Please sign in to comment.