From c66495b66c7a60679f99ad1fa6d7f3acc9caef9e Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Thu, 31 Mar 2016 20:30:40 +0100 Subject: [PATCH] Tighten C++ linting rules Bump benchmark dependencies Update leak test suppressions Update future branch details --- CONTRIBUTING.md | 2 +- src/common.cc | 35 ++++++++++++++++++++++------------- src/metadata.cc | 1 - src/pipeline.cc | 16 ++++++++-------- test/bench/package.json | 4 ++-- test/leak/sharp.supp | 13 +------------ test/unit/cpplint.js | 7 ++----- 7 files changed, 36 insertions(+), 42 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bc037b84..f9d16b4b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,9 +41,9 @@ Any change that modifies the existing public API should be added to the relevant | Release | WIP branch | | ------: | :--------- | -| v0.14.0 | needle | | v0.15.0 | outfit | | v0.16.0 | pencil | +| v0.17.0 | quill | Please squash your changes into a single commit using a command like `git rebase -i upstream/`. diff --git a/src/common.cc b/src/common.cc index 46872aa8..465ee79e 100644 --- a/src/common.cc +++ b/src/common.cc @@ -8,16 +8,16 @@ // Verify platform and compiler compatibility #if (VIPS_MAJOR_VERSION < 8 || (VIPS_MAJOR_VERSION == 8 && VIPS_MINOR_VERSION < 2)) -#error libvips version 8.2.0+ required - see http://sharp.dimens.io/page/install +#error libvips version 8.2.0+ required - see sharp.dimens.io/page/install #endif #if ((!defined(__clang__)) && defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6))) -#error GCC version 4.6+ is required for C++11 features - see http://sharp.dimens.io/page/install#prerequisites +#error GCC version 4.6+ is required for C++11 features - see sharp.dimens.io/page/install#prerequisites #endif #if (defined(__clang__) && defined(__has_feature)) #if (!__has_feature(cxx_range_for)) -#error clang version 3.0+ is required for C++11 features - see http://sharp.dimens.io/page/install#prerequisites +#error clang version 3.0+ is required for C++11 features - see sharp.dimens.io/page/install#prerequisites #endif #endif @@ -219,35 +219,44 @@ namespace sharp { int left = 0; int top = 0; switch (gravity) { - case 1: // North + case 1: + // North left = (inWidth - outWidth + 1) / 2; break; - case 2: // East + case 2: + // East left = inWidth - outWidth; top = (inHeight - outHeight + 1) / 2; break; - case 3: // South + case 3: + // South left = (inWidth - outWidth + 1) / 2; top = inHeight - outHeight; break; - case 4: // West + case 4: + // West top = (inHeight - outHeight + 1) / 2; break; - case 5: // Northeast + case 5: + // Northeast left = inWidth - outWidth; break; - case 6: // Southeast + case 6: + // Southeast left = inWidth - outWidth; top = inHeight - outHeight; - case 7: // Southwest + case 7: + // Southwest top = inHeight - outHeight; - case 8: // Northwest + case 8: + // Northwest break; - default: // Centre + default: + // Centre left = (inWidth - outWidth + 1) / 2; top = (inHeight - outHeight + 1) / 2; } return std::make_tuple(left, top); } -} // namespace sharp +} // namespace sharp diff --git a/src/metadata.cc b/src/metadata.cc index f451fedc..e88e8d1c 100644 --- a/src/metadata.cc +++ b/src/metadata.cc @@ -73,7 +73,6 @@ struct MetadataBaton { }; class MetadataWorker : public AsyncWorker { - public: MetadataWorker(Callback *callback, MetadataBaton *baton, const Local &bufferIn) : AsyncWorker(callback), baton(baton) { diff --git a/src/pipeline.cc b/src/pipeline.cc index dc7c38f7..16b25cde 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -71,7 +71,6 @@ using sharp::counterProcess; using sharp::counterQueue; class PipelineWorker : public AsyncWorker { - public: PipelineWorker(Callback *callback, PipelineBaton *baton, Callback *queueListener, const Local &bufferIn, const Local &overlayBufferIn) : @@ -89,7 +88,6 @@ class PipelineWorker : public AsyncWorker { libuv worker */ void Execute() { - // Decrement queued task counter g_atomic_int_dec_and_test(&counterQueue); // Increment processing task counter @@ -685,7 +683,8 @@ class PipelineWorker : public AsyncWorker { ->set("strip", !baton->withMetadata) ->set("compression", baton->compressionLevel) ->set("interlace", baton->progressive) - ->set("filter", baton->withoutAdaptiveFiltering ? VIPS_FOREIGN_PNG_FILTER_NONE : VIPS_FOREIGN_PNG_FILTER_ALL) + ->set("filter", baton->withoutAdaptiveFiltering ? + VIPS_FOREIGN_PNG_FILTER_NONE : VIPS_FOREIGN_PNG_FILTER_ALL) )); baton->bufferOut = static_cast(area->data); baton->bufferOutLength = area->length; @@ -758,7 +757,8 @@ class PipelineWorker : public AsyncWorker { ->set("strip", !baton->withMetadata) ->set("compression", baton->compressionLevel) ->set("interlace", baton->progressive) - ->set("filter", baton->withoutAdaptiveFiltering ? VIPS_FOREIGN_PNG_FILTER_NONE : VIPS_FOREIGN_PNG_FILTER_ALL) + ->set("filter", baton->withoutAdaptiveFiltering ? + VIPS_FOREIGN_PNG_FILTER_NONE : VIPS_FOREIGN_PNG_FILTER_ALL) ); baton->formatOut = "png"; } else if (baton->formatOut == "webp" || isWebp || (matchInput && inputImageType == ImageType::WEBP)) { @@ -882,10 +882,10 @@ class PipelineWorker : public AsyncWorker { case 6: rotate = VIPS_ANGLE_D90; break; case 3: rotate = VIPS_ANGLE_D180; break; case 8: rotate = VIPS_ANGLE_D270; break; - case 2: flop = TRUE; break; // flop 1 - case 7: flip = TRUE; rotate = VIPS_ANGLE_D90; break; // flip 6 - case 4: flop = TRUE; rotate = VIPS_ANGLE_D180; break; // flop 3 - case 5: flip = TRUE; rotate = VIPS_ANGLE_D270; break; // flip 8 + case 2: flop = TRUE; break; // flop 1 + case 7: flip = TRUE; rotate = VIPS_ANGLE_D90; break; // flip 6 + case 4: flop = TRUE; rotate = VIPS_ANGLE_D180; break; // flop 3 + case 5: flip = TRUE; rotate = VIPS_ANGLE_D270; break; // flip 8 } } else { if (angle == 90) { diff --git a/test/bench/package.json b/test/bench/package.json index b4c08fbd..9427a368 100644 --- a/test/bench/package.json +++ b/test/bench/package.json @@ -9,10 +9,10 @@ }, "devDependencies": { "async": "^1.5.2", - "benchmark": "^2.0.0", + "benchmark": "^2.1.0", "gm": "^1.21.0", "imagemagick": "^0.1.3", - "imagemagick-native": "elad/node-imagemagick-native", + "imagemagick-native": "^1.9.2", "jimp": "^0.2.20", "lwip": "^0.0.8", "semver": "^5.1.0" diff --git a/test/leak/sharp.supp b/test/leak/sharp.supp index 680ca215..dccdc3fc 100644 --- a/test/leak/sharp.supp +++ b/test/leak/sharp.supp @@ -306,26 +306,15 @@ ... fun:vips__magick_read_header } -{ - cond_magick_is_palette_image_get_bands - Memcheck:Cond - fun:IsPaletteImage - ... - fun:get_bands -} { value_magick_is_palette_image Memcheck:Value8 fun:IsPaletteImage - ... - fun:get_bands } { - cond_magick_is_palette_image_parse_header + cond_magick_is_palette_image Memcheck:Cond fun:IsPaletteImage - ... - fun:parse_header } # glib g_file_read_link diff --git a/test/unit/cpplint.js b/test/unit/cpplint.js index d02b92ff..44dc59b6 100644 --- a/test/unit/cpplint.js +++ b/test/unit/cpplint.js @@ -19,18 +19,15 @@ describe('cpplint', function() { // Lint each source file cpplint({ files: [file], - linelength: 140, + linelength: 120, filters: { legal: { copyright: false }, build: { - include: false, - include_order: false + include: false }, whitespace: { - blank_line: false, - comments: false, parens: false } }