Skip to content

lodepng_unittest.cpp from lodepng#18

Open
pavel-ignatovich wants to merge 1 commit intomasterfrom
c_lodepng_unittest.cpp
Open

lodepng_unittest.cpp from lodepng#18
pavel-ignatovich wants to merge 1 commit intomasterfrom
c_lodepng_unittest.cpp

Conversation

@pavel-ignatovich
Copy link
Copy Markdown

Copy link
Copy Markdown

@monocodus monocodus Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is autogenerated code-style review, only first 25 of 33 new suggestions are shown

Comment thread lodepng_unittest.cpp
#include <string>
#include <vector>

#include <stdio.h>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include <stdio.h>
#include <cstdio>

This comment was generated with the following checker: ClangTidy

Comment thread lodepng_unittest.cpp
#include <vector>

#include <stdio.h>
#include <stdlib.h>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include <stdlib.h>
#include <cstdlib>

This comment was generated with the following checker: ClangTidy

Comment thread lodepng_unittest.cpp

//assert that no error
void assertNoPNGError(unsigned error, const std::string& message = "") {
if(error) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(error) {
if(error != 0u) {

This comment was generated with the following checker: ClangTidy

Comment thread lodepng_unittest.cpp
}

void assertNoError(unsigned error) {
if(error) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(error) {
if(error != 0u) {

This comment was generated with the following checker: ClangTidy

Comment thread lodepng_unittest.cpp

//Test LodePNG encoding and decoding the encoded result, using the C interface
void doCodecTestC(Image& image) {
unsigned char* encoded = 0;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
unsigned char* encoded = 0;
unsigned char* encoded = nullptr;

This comment was generated with the following checker: ClangTidy

Comment thread lodepng_unittest.cpp
//Generate a 16-bit test image with minimal size that requires at minimum the given color type (bit depth, grayscaleness, ...)
//If key is true, makes it such that exactly one color is transparent, so it can use a key. If false, adds a translucent color depending on
//whether it's an alpha color type or not.
void generateTestImageRequiringColorType16(Image& image, LodePNGColorType colorType, unsigned bitDepth, bool key) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is too complicated

generateTestImageRequiringColorType16( Image & image , LodePNGColorType colorType , unsigned bitDepth , bool key) now has cyclomatic complexity of 26.
Corresponding modifications started here.
Split your routines to keep cyclomatic complexity below 10 to improve their maintainability.

This comment was generated with the following checker: high_cyclomatic_complexity

Comment thread lodepng_unittest.cpp
//Generate a 8-bit test image with minimal size that requires at minimum the given color type (bit depth, grayscaleness, ...). bitDepth max 8 here.
//If key is true, makes it such that exactly one color is transparent, so it can use a key. If false, adds a translucent color depending on
//whether it's an alpha color type or not.
void generateTestImageRequiringColorType8(Image& image, LodePNGColorType colorType, unsigned bitDepth, bool key) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is too complicated

generateTestImageRequiringColorType8( Image & image , LodePNGColorType colorType , unsigned bitDepth , bool key) now has cyclomatic complexity of 16.
Corresponding modifications started here.
Split your routines to keep cyclomatic complexity below 10 to improve their maintainability.

This comment was generated with the following checker: high_cyclomatic_complexity

Comment thread lodepng_unittest.cpp
}

// Tests combinations of various colors in different orders
void testFewColors() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is too complicated

testFewColors() now has cyclomatic complexity of 19.
Corresponding modifications started here.
Split your routines to keep cyclomatic complexity below 10 to improve their maintainability.

This comment was generated with the following checker: high_cyclomatic_complexity

Comment thread lodepng_unittest.cpp

//This tests color conversions from any color model to any color model, with any bit depth
//But it tests only with colors black and white, because that are the only colors every single model supports
void testColorConvert2() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is too complicated

testColorConvert2() now has cyclomatic complexity of 12.
Corresponding modifications started here.
Split your routines to keep cyclomatic complexity below 10 to improve their maintainability.

This comment was generated with the following checker: high_cyclomatic_complexity

Comment thread lodepng_unittest.cpp
ASSERT_EQUALS(5, h);
}

void test
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is too complicated

testAutoColorModels() now has cyclomatic complexity of 15.
Corresponding modifications started here.
Split your routines to keep cyclomatic complexity below 10 to improve their maintainability.

This comment was generated with the following checker: high_cyclomatic_complexity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C/C++ Files in C or C++ Demonstration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant