diff --git a/.arcconfig b/.arcconfig --- a/.arcconfig +++ b/.arcconfig @@ -1,4 +1,4 @@ { - "phabricator.uri" : "https://phabricator.services.mozilla.com/", + "phabricator.uri" : "https://phabricator-dev.allizom.org/", "repository.callsign": "MOZILLACENTRAL" } diff --git a/devtools/client/definitions.js b/devtools/client/definitions.js --- a/devtools/client/definitions.js +++ b/devtools/client/definitions.js @@ -2,11 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -const Services = require("Services"); +const Services=require("Services"); // space-infix-ops (eslint) const osString = Services.appinfo.OS; // Panels loader.lazyGetter(this, "OptionsPanel", () => require("devtools/client/framework/toolbox-options").OptionsPanel); loader.lazyGetter(this, "InspectorPanel", () => require("devtools/client/inspector/panel").InspectorPanel); diff --git a/devtools/client/menus.js b/devtools/client/menus.js --- a/devtools/client/menus.js +++ b/devtools/client/menus.js @@ -1,10 +1,10 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -"use strict"; +// "use strict"; // strict (eslint) /** * This module defines the sorted list of menuitems inserted into the * "Web Developer" menu. * It also defines the key shortcuts that relates to them. @@ -34,10 +34,12 @@ loader.lazyRequireGetter(this, "ResponsiveUIManager", "devtools/client/responsive.html/manager", true); loader.lazyImporter(this, "BrowserToolboxProcess", "resource://devtools/client/framework/ToolboxProcess.jsm"); loader.lazyImporter(this, "ScratchpadManager", "resource://devtools/client/scratchpad/scratchpad-manager.jsm"); + // no-tabs (eslint) + exports.menuitems = [ { id: "menu_devToolbox", l10nKey: "devToolboxMenuItem", oncommand(event) { let window = event.target.ownerDocument.defaultView; diff --git a/devtools/client/shared/scroll.js b/devtools/client/shared/scroll.js --- a/devtools/client/shared/scroll.js +++ b/devtools/client/shared/scroll.js @@ -2,11 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -// Make this available to both AMD and CJS environments +# Make this available to both AMD and CJS environments // Parsing error: Unexpected character '#' (eslint) define(function (require, exports, module) { /** * Scroll the document so that the element "elem" appears in the viewport. * * @param {DOMNode} elem diff --git a/js/src/ctypes/libffi/src/prep_cif.c b/js/src/ctypes/libffi/src/prep_cif.c --- a/js/src/ctypes/libffi/src/prep_cif.c +++ b/js/src/ctypes/libffi/src/prep_cif.c @@ -83,11 +83,11 @@ arg->alignment = FFI_AGGREGATE_ALIGNMENT; #endif if (arg->size == 0) return FFI_BAD_TYPEDEF; - else + else // readability-else-after-return return FFI_OK; } #ifndef __CRIS__ /* The CRIS ABI specifies structure elements to have byte diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -6,10 +6,12 @@ /* * JavaScript API. */ +#include + #include "jsapi.h" #include "mozilla/FloatingPoint.h" #include "mozilla/Maybe.h" #include "mozilla/PodOperations.h" @@ -113,10 +115,15 @@ #define JS_ADDRESSOF_VA_LIST(ap) ((va_list*)(ap)) #else #define JS_ADDRESSOF_VA_LIST(ap) (&(ap)) #endif +class AnnotateConflict { + MOZ_NO_DANGLING_ON_TEMPORARIES int *get() && { return nullptr; } // mozilla-dangling-on-temporary + MOZ_NO_DANGLING_ON_TEMPORARIES int test() { return 0; } // mozilla-dangling-on-temporary +}; + JS_PUBLIC_API(bool) JS::CallArgs::requireAtLeast(JSContext* cx, const char* fnname, unsigned required) const { if (length() < required) { char numArgsStr[40]; @@ -160,13 +167,11 @@ unsigned flags = strict ? JSREPORT_ERROR : (JSREPORT_WARNING | JSREPORT_STRICT); if (code_ == JSMSG_OBJECT_NOT_EXTENSIBLE) { RootedValue val(cx, ObjectValue(*obj)); return ReportValueErrorFlags(cx, flags, code_, JSDVG_IGNORE_STACK, val, nullptr, nullptr, nullptr); - } - - if (ErrorTakesArguments(code_)) { + } else if (ErrorTakesArguments(code_)) { // readability-misleading-indentation or readability-else-after-return RootedValue idv(cx, IdToValue(id)); RootedString str(cx, ValueToSource(cx, idv)); if (!str) return false; @@ -305,16 +310,22 @@ } JS_PUBLIC_API(Value) JS_GetEmptyStringValue(JSContext* cx) { + std::string str; + str.find("A"); // performance-faster-string-find + return StringValue(cx->runtime()->emptyString); } JS_PUBLIC_API(JSString*) JS_GetEmptyString(JSContext* cx) { + std::map> my_map; + for (const std::pair>& p : my_map) {} // performance-implicit-conversion-in-loop + MOZ_ASSERT(cx->emptyString()); return cx->emptyString(); } namespace js { diff --git a/js/src/jsapi.cpp.rej b/js/src/jsapi.cpp.rej new file mode 100644 --- /dev/null +++ b/js/src/jsapi.cpp.rej @@ -0,0 +1,22 @@ +--- jsapi.cpp ++++ jsapi.cpp +@@ -163,18 +170,17 @@ JS::ObjectOpResult::reportStrictErrorOrW + MOZ_ASSERT(!ok()); + assertSameCompartment(cx, obj); + + unsigned flags = strict ? JSREPORT_ERROR : (JSREPORT_WARNING | JSREPORT_STRICT); + if (code_ == JSMSG_OBJECT_NOT_EXTENSIBLE || code_ == JSMSG_SET_NON_OBJECT_RECEIVER) { + RootedValue val(cx, ObjectValue(*obj)); + return ReportValueErrorFlags(cx, flags, code_, JSDVG_IGNORE_STACK, val, + nullptr, nullptr, nullptr); +- } +- if (ErrorTakesArguments(code_)) { ++ } else if (ErrorTakesArguments(code_)) { // readability-misleading-indentation or readability-else-after-return + RootedValue idv(cx, IdToValue(id)); + RootedString str(cx, ValueToSource(cx, idv)); + if (!str) + return false; + + JSAutoByteString propName; + if (!propName.encodeUtf8(cx, str)) + return false; diff --git a/js/src/util/AllocPolicy.cpp b/js/src/util/AllocPolicy.cpp --- a/js/src/util/AllocPolicy.cpp +++ b/js/src/util/AllocPolicy.cpp @@ -2,22 +2,49 @@ * vim: set ts=8 sts=4 et sw=4 tw=99: * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "js/AllocPolicy.h" +#include +#include +#include "js/AllocPolicy.h" #include "vm/JSContext.h" using namespace js; +const char* Test[] = { + "line 1", + "line 2" // misc-suspicious-missing-comma + "line 3", + "line 4", + "line 5" +}; + void* TempAllocPolicy::onOutOfMemory(AllocFunction allocFunc, size_t nbytes, void* reallocPtr) { + for (float x = 0.1f; x <= 1.0f; x += 0.1f) {} // clang-analyzer-security.FloatLoopCounter + + setuid(1); // clang-analyzer-security.insecureAPI.UncheckedReturn + + char buff[1024]; + gets(buff); // security.insecureAPI.gets + + int x = 0; + int y = 0; + if (x < y); // misc-suspicious-semicolon + { + x++; + } + return cx_->onOutOfMemory(allocFunc, nbytes, reallocPtr); } void -TempAllocPolicy::reportAllocOverflow() const +TempAllocPolicy::reportAllocOverflow(void) const // modernize-redundant-void-arg { + int x; + x = 1; // clang-analyzer-deadcode.DeadStores + ReportAllocationOverflow(cx_); } diff --git a/patch.diff b/patch.diff new file mode 100644 --- /dev/null +++ b/patch.diff @@ -0,0 +1,172 @@ +diff --git a/js/src/ctypes/libffi/src/prep_cif.c b/js/src/ctypes/libffi/src/prep_cif.c +--- a/js/src/ctypes/libffi/src/prep_cif.c ++++ b/js/src/ctypes/libffi/src/prep_cif.c +@@ -80,17 +80,17 @@ static ffi_status initialize_aggregate(f + alignment beyond the "natural" one based on their elements. */ + #ifdef FFI_AGGREGATE_ALIGNMENT + if (FFI_AGGREGATE_ALIGNMENT > arg->alignment) + arg->alignment = FFI_AGGREGATE_ALIGNMENT; + #endif + + if (arg->size == 0) + return FFI_BAD_TYPEDEF; +- else ++ else // readability-else-after-return + return FFI_OK; + } + + #ifndef __CRIS__ + /* The CRIS ABI specifies structure elements to have byte + alignment only, so it completely overrides this functions, + which assumes "natural" alignment and padding. */ + +diff --git a/js/src/jsalloc.cpp b/js/src/jsalloc.cpp +--- a/js/src/jsalloc.cpp ++++ b/js/src/jsalloc.cpp +@@ -1,23 +1,51 @@ + /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=8 sts=4 et sw=4 tw=99: + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + ++#include ++#include ++ + #include "jsalloc.h" + + #include "jscntxt.h" + + using namespace js; + ++const char* Test[] = { ++ "line 1", ++ "line 2" // misc-suspicious-missing-comma ++ "line 3", ++ "line 4", ++ "line 5" ++}; ++ + void* + TempAllocPolicy::onOutOfMemory(AllocFunction allocFunc, size_t nbytes, void* reallocPtr) + { ++ for (float x = 0.1f; x <= 1.0f; x += 0.1f) {} // clang-analyzer-security.FloatLoopCounter ++ ++ setuid(1); // clang-analyzer-security.insecureAPI.UncheckedReturn ++ ++ char buff[1024]; ++ gets(buff); // security.insecureAPI.gets ++ ++ int x = 0; ++ int y = 0; ++ if (x < y); // misc-suspicious-semicolon ++ { ++ x++; ++ } ++ + return cx_->onOutOfMemory(allocFunc, nbytes, reallocPtr); + } + + void +-TempAllocPolicy::reportAllocOverflow() const ++TempAllocPolicy::reportAllocOverflow(void) const // modernize-redundant-void-arg + { ++ int x; ++ x = 1; // clang-analyzer-deadcode.DeadStores ++ + ReportAllocationOverflow(cx_); + } +diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp +--- a/js/src/jsapi.cpp ++++ b/js/src/jsapi.cpp +@@ -3,16 +3,18 @@ + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + /* + * JavaScript API. + */ + ++#include ++ + #include "jsapi.h" + + #include "mozilla/FloatingPoint.h" + #include "mozilla/Maybe.h" + #include "mozilla/PodOperations.h" + #include "mozilla/Sprintf.h" + + #include +@@ -116,16 +118,21 @@ using JS::ToInteger; + using JS::ToUint32; + + #ifdef HAVE_VA_LIST_AS_ARRAY + #define JS_ADDRESSOF_VA_LIST(ap) ((va_list*)(ap)) + #else + #define JS_ADDRESSOF_VA_LIST(ap) (&(ap)) + #endif + ++class AnnotateConflict { ++ MOZ_NO_DANGLING_ON_TEMPORARIES int *get() && { return nullptr; } // mozilla-dangling-on-temporary ++ MOZ_NO_DANGLING_ON_TEMPORARIES int test() { return 0; } // mozilla-dangling-on-temporary ++}; ++ + JS_PUBLIC_API(bool) + JS::CallArgs::requireAtLeast(JSContext* cx, const char* fnname, unsigned required) const + { + if (length() < required) { + char numArgsStr[40]; + SprintfLiteral(numArgsStr, "%u", required - 1); + JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, + fnname, numArgsStr, required == 2 ? "" : "s"); +@@ -163,18 +170,17 @@ JS::ObjectOpResult::reportStrictErrorOrW + MOZ_ASSERT(!ok()); + assertSameCompartment(cx, obj); + + unsigned flags = strict ? JSREPORT_ERROR : (JSREPORT_WARNING | JSREPORT_STRICT); + if (code_ == JSMSG_OBJECT_NOT_EXTENSIBLE || code_ == JSMSG_SET_NON_OBJECT_RECEIVER) { + RootedValue val(cx, ObjectValue(*obj)); + return ReportValueErrorFlags(cx, flags, code_, JSDVG_IGNORE_STACK, val, + nullptr, nullptr, nullptr); +- } +- if (ErrorTakesArguments(code_)) { ++ } else if (ErrorTakesArguments(code_)) { // readability-misleading-indentation or readability-else-after-return + RootedValue idv(cx, IdToValue(id)); + RootedString str(cx, ValueToSource(cx, idv)); + if (!str) + return false; + + JSAutoByteString propName; + if (!propName.encodeUtf8(cx, str)) + return false; +@@ -296,22 +302,28 @@ JS_PUBLIC_API(Value) + JS_GetPositiveInfinityValue(JSContext* cx) + { + return cx->runtime()->positiveInfinityValue; + } + + JS_PUBLIC_API(Value) + JS_GetEmptyStringValue(JSContext* cx) + { ++ std::string str; ++ str.find("A"); // performance-faster-string-find ++ + return StringValue(cx->runtime()->emptyString); + } + + JS_PUBLIC_API(JSString*) + JS_GetEmptyString(JSContext* cx) + { ++ std::map> my_map; ++ for (const std::pair>& p : my_map) {} // performance-implicit-conversion-in-loop ++ + MOZ_ASSERT(cx->emptyString()); + return cx->emptyString(); + } + + namespace js { + + void + AssertHeapIsIdle() + diff --git a/toolkit/components/telemetry/gen_event_data.py b/toolkit/components/telemetry/gen_event_data.py --- a/toolkit/components/telemetry/gen_event_data.py +++ b/toolkit/components/telemetry/gen_event_data.py @@ -30,11 +30,11 @@ """ def write_extra_table(events, output, string_table): table_name = "gExtraKeysTable" - extra_table = [] + extra_table=[] # missing whitespace around operator E225 (flake8); at least two spaces before inline comment E261 (flake8); line too long (126 > 99 characters) E501 (flake8) extra_count = 0 print("const uint32_t %s[] = {" % table_name, file=output) for e in events: @@ -50,11 +50,11 @@ ", ".join(e.methods), ", ".join(e.objects)), file=output) print(" // extra_keys: %s" % ", ".join(extra_keys), file=output) print(" %s," % ", ".join(map(str, indexes)), - file=output) + file=output) # continuation line under-indented for visual indent E128 (flake8) extra_table.append((extra_index, len(extra_keys))) print("};", file=output) static_assert(output, "sizeof(%s) <= UINT32_MAX" % table_name,