Questions tagged [google-style-guide]

The Google Style Guide project holds the style guidelines googlers use for Google code.

Every major open-source project has its own style guide: a set of conventions (sometimes arbitrary) about how to write code for that project. It is much easier to understand a large codebase when all the code in it is in a consistent style.

“Style” covers a lot of ground, from “use camelCase for variable names” to “never use global variables” to “never use exceptions.” The Google Style Guide project holds the style guidelines we use for Google code. If you are modifying a project that originated at Google, you may be pointed to its page to see the style guides that apply to that project.

74 questions
1
vote
0 answers

Why Google Style Guide recommend local variables for shell scripts but does not use it in examples?

Google Style Guide says to always use local variables and put everything into function. On the other hand sample for loop is provided: for dir in ${dirs_to_cleanup}; do ... done Why there is no convention to always declare loop variable as local…
Michal Kordas
  • 10,475
  • 7
  • 58
  • 103
1
vote
0 answers

Protobuf and exceptions

So I was reading about protobuf exception handling, and I've read the following document: https://groups.google.com/forum/#!topic/protobuf/IFcZQK0QuzI specifically: We don't use exceptions in protobuf as exceptions are disallowed per Google C++…
ByoTic
  • 333
  • 1
  • 4
  • 16
1
vote
1 answer

Error running PuppyCrawl's Maven Checkstyle Plugin

Well, I'm trying to configure Maven's Checkstyle Plugin on the project I'm currently working on and I'm getting the following: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:check (verify-style) on project…
Jaumzera
  • 2,305
  • 1
  • 30
  • 44
1
vote
3 answers

Using a class in a header file without access to its definition?

This is excerpt from google's c++ coding guidelines. How can we use a class Foo in a header file without access to its definition? We can declare data members of type Foo* or Foo&. We can declare (but not define) functions with arguments,…
LavaScornedOven
  • 737
  • 1
  • 11
  • 23
1
vote
0 answers

How to install CppStyle in Eclipse?

I would like to use the CppStyle Plugin in Eclipse within my projects, but I have some problems during the installation: I tried to install it using the Eclipse Marketplace, but I get the fallowing error: The following solutions are not available:…
eDeviser
  • 1,605
  • 2
  • 17
  • 44
1
vote
1 answer

AStyle for Google C++ style guide

I just started using Astyle with VS-2013 for C++. I want to configure it to follow the Google C++ style guide. I noticed that Astyle allows configuration files to be imported, so I was wondering has somebody done the hard work and configured it to…
ahmadh
  • 1,582
  • 2
  • 18
  • 28
1
vote
1 answer

What top level code is executed on import

In Google python style guide it states (towards the end for "Main") "All code at the top level will be executed when the module is imported" I'm under the impression that top level code is any code in a module(file) that is indented at 0. So…
Angel Cloudwalker
  • 2,015
  • 5
  • 32
  • 54
1
vote
1 answer

Property definition is method definition when using knockout

According to the Google style guide, methods should be defined on the prototype of a constructor and properties should be defined in the constructor using the this keyword. I do most of my front end development using Knockout, which handles…
Matthew James Davis
  • 12,134
  • 7
  • 61
  • 90
0
votes
1 answer

Pdoc doesn't recognize Google-Style

I am trying to use the google-style directive with pdoc, but it doesn't work on my side. Where am I wrong? Below is my code. Please help me. :) def save(a: str, b:str) -> set: """ Do something Args: …
sam
  • 19
  • 1
  • 4
0
votes
0 answers

Enforcing argument and return documentation in the docstring

I'm trying to add a linter to a repo that would enforce docstring documentation of arguments and return values for functions and methods, as described in the Google Python Style Guide. In general, I want to enforce the following docstring…
Adam Matan
  • 128,757
  • 147
  • 397
  • 562
0
votes
2 answers

Docstring for class functions that only adds/updates class attributes?

I'm trying to follow the Google Style of docstrings, but I'm not sure how to document a function (and the class itself) when there's functions that add/supdates an attribute. Currently I have something like this: class myclass(): """This is an…
Esteban
  • 179
  • 8
0
votes
1 answer

what is the proper case of constant class member fields according to the google c++ style guide?

according to https://google.github.io/styleguide/cppguide.html#Variable_Names, Data members of classes, both static and non-static, are named like ordinary nonmember variables, but with a trailing underscore. according to…
Kamen
  • 47
  • 7
0
votes
1 answer

Not deleting a static pointer (google style)

According to Google C++ Style Guide - Static and Global Variables, Decision on Destructions ... Therefore, we only allow objects with static storage duration if they are trivially destructible. Common Patterns ... Maps, sets, and other dynamic…
김선달
  • 1,485
  • 9
  • 23
0
votes
1 answer

ESLint Question: Standard guide, or a popular style guide

As a beginner should I be using a standard guide, a popular style guide or should I be working on creating my own file based on my own preferences?
0
votes
2 answers

Google C# style guide reasoning is unclear

I found Google C# style guide and these points For inputs use the most restrictive collection type possible, for example IReadOnlyCollection / IReadOnlyList / IEnumerable as inputs to methods when the inputs should be immutable. For outputs, if…