Questions tagged [oclint]

OCLint is a static code analysis tool for improving the quality of C, C++ and primarily Objective-C. Code analysis reduces defects by inspecting the code and looking for potential problems.

OCLint is a static code analysis tool for improving quality and reducing defects by inspecting C, C++ and Objective-C code and looking for potential problems like:

  • Possible bugs - empty if/else/try/catch/finally statements.
  • Unused code - unused local variables and parameters
  • Complicated code - high cyclomatic complexity, NPath complexity and high NCSS
  • Redundant code - redundant if statement and useless parentheses
  • Code smells - long method and long parameter list
  • Bad practices - inverted logic and parameter reassignment

Static code analysis is a critical technique to detect defects that aren't visible to compilers. OCLint automates this inspection process with advanced features:

Relying on the abstract syntax tree of the source code for better accuracy and efficiency; False positives are mostly reduced to avoid useful results sinking in them. Dynamically loading rules into system, even in the runtime. Flexible and extensible configurations ensure users in customizing the behaviors of the tool. Command line invocation facilitates continuous integration and continuous inspection of the code while being developed, so that technical debts can be fixed early on to reduce the maintenance cost.

48 questions
10
votes
1 answer

OCLint ASTMatcher rule. Matching NS_ENUM

I am trying to create an OCLint rule that matches both typedef enum and typedef NS_ENUM declarations, with little success. I have an Objective-C file (TestClass.m) with the following enum declarations in it: typedef NS_ENUM(NSInteger, TestEnum) { …
danielbeard
  • 9,120
  • 3
  • 44
  • 58
10
votes
7 answers

How to get the size of a type in C++?

I am looking for a C++ function that returns the size of a type. For example : #include int16_t my_var; int32_t size_of_var; // magical_function is what I'm looking for // size_of_var should be equal to 16 because my_var is a…
Marc-O
  • 701
  • 1
  • 5
  • 22
6
votes
0 answers

why error "accessing build database disk I/O error"?

When I use Xcode10.2.1 run Oclint target,there is a error as below: Build system information :-1: error: accessing build database …
Scott
  • 162
  • 1
  • 12
6
votes
1 answer

How to use OCLint for the Cocoa Framework?

Run the following command in the folder with the project: $ xcodebuild -target MyCocoaFramework -configuration Debug -scheme MyCocoaFramework clean build | tee xcodebuild.log $ oclint-xcodebuild $ oclint-json-compilation-database $ Nothing is…
abg
  • 2,002
  • 7
  • 39
  • 63
6
votes
6 answers

xcodebuild generating empty compile_commands.json

I am using following commands to use the oclint with xcode 5- Step1: xcodebuild -target OClintDemo -configuration Debug -scheme OClintDemo -sdk iphonesimulator Step2: OClintDemo jenkins$ xcodebuild -sdk iphonesimulator | tee xcodebuild.log Step3:…
iGagan Kumar
  • 406
  • 8
  • 26
5
votes
1 answer

OCLint Xcode 9.3.1 Failure

I have the following Run Script , available at http://oclint-docs.readthedocs.io/en/stable/guide/xcode.html source ~/.bash_profile cd ${SRCROOT} xcodebuild clean xcodebuild | xcpretty -r json-compilation-database --output…
NNikN
  • 3,720
  • 6
  • 44
  • 86
5
votes
1 answer

OCLint generate html report error

I'm trying to generate an html report from OCLint analysis. I've installed xctool and generate the json file with this command: xcodebuild -workspace SecondHand.xcworkspace -scheme SecondHand -sdk iphonesimulator build | tee xcodebuild.log |…
yaoweili
  • 51
  • 3
5
votes
0 answers

Xcode Analyzer vs OCLint in 2016

Is there any reason to use OCLint over Xcode's Analyze tool on Xcode 7? All the posts and information that I can find online date from 2013 or older, but I know Xcode improved quite a bit with it's tools since then, like we didn't have code…
Jan
  • 2,462
  • 3
  • 31
  • 56
3
votes
1 answer

OCLint got compile errors in html report file, but my project build success. WHY

xcodebuild -workspace ${myworkspace} -scheme ${myscheme} \ -sdk iphonesimulator \ -derivedDataPath ./build/derivedData \ -configuration Debug \ COMPILER_INDEX_STORE_ENABLE=NO \ | xcpretty -r json-compilation-database -o…
3
votes
0 answers

OCLint without running xcodebuild in run script

I've been trying to add OCLint to my project and it mostly works with cd ${SRCROOT} xcodebuild clean xcodebuild -target {TARGET} -configuration Debug -scheme {SCHEME} | tee ${TARGET_TEMP_DIR}/xcodebuild.log cd…
DranoMax
  • 474
  • 4
  • 18
3
votes
1 answer

How to reduce high cyclomatic complexity while initializing from NSUserDefaults

I have this initializer for an object: -(id)init { self = [super init]; if (self) { if([[NSUserDefaults standardUserDefaults] objectForKey:kTermsAccepted] != nil){ _termsAccepted = [[NSUserDefaults standardUserDefaults]…
Jan
  • 2,462
  • 3
  • 31
  • 56
3
votes
1 answer

OCLint not in system path

I have an Xcode project. I tried to integrate OcLint in it. But it says there is no OCLint.How can I download and addOCLint to my system path so that I can integrateOCLint in my xcode project. EDIT: When I have a partof OCLint script as hash oclint…
Nevin Raj Victor
  • 2,924
  • 3
  • 23
  • 37
3
votes
1 answer

How can I compare two source locations in clang?

this seems to be more a C++ problem rather than a Clang problem... I have to use C++ in order to write an OCLint (static code analyzer) rule. I wish to compare two objects from the Clang library that have the type "SourceLocation". This type…
Marc-O
  • 701
  • 1
  • 5
  • 22
3
votes
2 answers

oclint: oclint-json-compilation-database returns "Skipping [Path] Command line not found."

After (seemingly) successfully generating compile_commands.json with oclint-xcodebuild, oclint-json-compilation-database fails to correctly create a pmd-style report. The command looks like this: oclint-json-compilation-database -e Pods -v --…
ff10
  • 3,046
  • 1
  • 32
  • 55
2
votes
0 answers

OClint warning confusion for C

I have a program with the following line of code in it if (counter % 2 == 1){ and OClint is giving me the warning "broken oddness check", which from the documentation states that it won't work for negative numbers, which I understand, but the…
William
  • 81
  • 5
1
2 3 4